I’m making a button simulator game and I put this script in a part.
script.Parent.Touched:Connect(function(hit)
local player = hit.Parent.Name
local gameplayer = game.Players[player]
if gameplayer.leaderstats.Clicks.Value >= 50 then
gameplayer.leaderstats.Clicks.Value = gameplayer.leaderstats.Clicks.Value - 50
gameplayer.leaderstats.Multiplier.Value = gameplayer.leaderstats.Multiplier.Value + 1
end
end)
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
local leaderstats = plr:findFirstChild('leaderstats')
if not leaderstats then print('no leaderstats') return end
local Clicks = leaderstats:findFirstChild('Clicks')
if not Clicks then print('no clicks val') return end
local Multiplier = leaderstats:findFirstChild('Multiplier')
if not Multiplier then print('no multiplier') return end
if Clicks.Value >= 50 then
Clicks.Value = Clicks.Value - 50
Multiplier.Value = Multiplier.Value + 1
end
end
end)
It’s a regular script in Workspace. If we can’t figure this problem out, I’m just gonna do clickDetection which is really inefficient for a Button Simulator.
(im talking about the first image and if its a model and its in a part it wont change anyhting)
that doesn’t change anything, i really don’t understand whats going on here, thats confusing
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
local plrClick = leaderstats:WaitForChild("Clicks")
local plrMulti = leaderstats:WaitForChild("Multiplier")
while wait(0.1) do
plrClick.Value += (1 + (1*plrMulti.Value))
end
end)