So I had made a code, and I made a script, but it didn't increase the value. Any solutions?
Faulty code:
enabled = true script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and enabled and script.Parent.Useable == true then local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100 script.Parent.Useable.Value = false script.Parent.Parent.TQ1.Useable = true wait(1) enabled = true end end)
I'm assuming it's to do with the fact that you're missing a .Value
from lines 4 and 11 after Useable
. The if/then block on line 4 will never be true because you are comparing script.Parent.Useable
, an Instance, to true
, a boolean, which will never be equal. Instead, you need to check for the value.
Your code with fixes:
enabled = true script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and enabled and script.Parent.Useable.Value == true then local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100 script.Parent.Useable.Value = false script.Parent.Parent.TQ1.Useable.Value = true wait(1) enabled = true end end)