I have a local script that gives the player an amount of money every 10 seconds if the part is in workspace. The part is teleported to workspace when the button is pressed. However, it doesn’t print what it is supposed to, or do anything else.
if part.Parent == ws then
print("poof")
event:FireServer(plr)
end
event.OnServerEvent:Connect(function(plr)
while true do
sound:Play()
print("yippee")
plr.leaderstats.Money.Value += 2
wait(10)
end
end)
Not sure how your doing things but these changes may help you:
LOCAL:
part.Changed:Connect(function(property)
if property == "Parent" then
print("poof")
event:FireServer()
end
end)
SERVER:
local reward = true
event.OnServerEvent:Connect(function(plr)
while reward do
reward = false
-- check if part is in workspace
if part.Parent == ws then
sound:Play()
print("yippee")
plr.leaderstats.Money.Value += 2
wait(10)
reward = true
else
reward = false
return
end
end
end)
Changing values on the client does not work, you’ll have to do this:
button.MouseButton1Click:Connect(function()
if player.leaderstats.Money.Value >= 5000 then
event:FireServer(player)
script:Destroy()
else
print("Unavailable Money")
sound:Play()
end
end)
I’m not sure what you mean by “does not work”, however, if you mean that the script is interfering with the script, then I don’t think so. I used the same script on a different item and it works perfectly.