✓ Accepted answer
When you set a variable to a ValueObject's Value property, that variable becomes equivalent to what the Value was when the script executed that line of code.
By changing the variable, you are simply changing the variable. The ValueObject's value is not affected.
You need to reference the object from the variable, and index the property to set it.
Now, secondly, you are getting the Player incorrectly. Since this is a server script you cannot use game.Players.LocalPlayer. You need to get the player some other way. That way is up to you. Preferably by an 'owner' StringValue to the tycoon.
local plr
local worth = plr:WaitForChild("leaderstats"):WaitForChild("Money")
function destroy(hit)
if hit.Name == "drop" then
worth.Value = worth.Value + 10
hit:Destroy()
end
end
script.Parent.Touched:connect(destroy)
1 comment
Explain the reason behind your answer plz. Thanx. c;