v.ButtonPart.Touched:Connect(function(Hit)
if Hit:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Values.OwnerValue.Value == player then
if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 0 then
if player:WaitForChild("leaderstats").Cash.Value >= v.Price.Value then
player.leaderstats.Cash.Value -= v.Price.Value
items[v.items.Value].Parent = Boughtitems
end
end
end
end
end)
我的按钮不起作用,我认为这里有错误,如果您可以在 roblox studio 中提供帮助,请回复您的用户,我添加您
我假设您希望该按钮在单击时激活,但我看到 .Touched:Connect。这可以检测该部件何时被另一个物体触摸/撞击。要检测点击,您需要有一个点击检测器元素作为按钮部分的子元素。然后将脚本内的点击检测器定义为
local clickDetector = script.Parent.ClickDetector
。不要使用 ButtonPart.Touched:Connect
,而是尝试使用 clickDetector.MouseClick:Connect
。