I am making job for my game it is pizza delivery and i am making script to give money and score to player but when i try to change value nothing happend no errors or something it even print started so i want ask if somebody dont know what to do :c
workspace.Locations.GiveMoney.OnServerEvent:Connect(function() lplayer = script.Parent.Parent money = script.Parent.Parent.leaderstats.Money delivery = script.Parent.Parent.leaderstats.Deliveris okpizzajob = lplayer.Jobs.OKpizza if okpizzajob.Value == 1 then pizzatype = script.Parent.OKpizza.Job.Take.Pizza delivery.Value = delivery.Value + 1 wait(0.1) if pizzatype.Value == 1 then money.Value = money.Value + 10 end wait(0.1) if pizzatype.Value == 2 then money.Value = money.Value + 15 end wait(0.1) if pizzatype.Value == 3 then money.Value = money.Value + 20 end end end)
First, put your Remote Event in ReplicatedStorage (recommanded)
game.ReplicatedStorage.GiveMoney.OnServerEvent:Connect(function(player) local money = player.leaderstats.Money local delivery = player.leaderstats.Deliveris local okpizzajob = player.Jobs.OKpizza if okpizzajob.Value == 1 then local pizzatype = okpizzajob.Job.Take.Pizza delivery.Value = delivery.Value + 1 wait(0.1) if pizzatype.Value == 1 then money.Value = money.Value + 10 end wait(0.1) if pizzatype.Value == 2 then money.Value = money.Value + 15 end wait(0.1) if pizzatype.Value == 3 then money.Value = money.Value + 20 end end end)
And put this script in ServerScriptService. Do double-check the variables and their location.
Please upvote and lemmeknow if it helps!
Edit: As discussed with you in Discord, the working script is:
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() money = player.leaderstats.Money delivery = player.leaderstats.Delivery gui = player.PlayerGui okpizzajob = player.Jobs.OKpizza game.ReplicatedStorage.GiveMoney.OnServerEvent:Connect(function() print(okpizzajob.Value) if okpizzajob.Value == 1 then pizzatype = gui.OKpizza.Job.Take.Pizza print(pizzatype.Value) if pizzatype.Value == 1 then money.Value = money.Value + 10 print("Money Given") elseif pizzatype.Value == 2 then money.Value = money.Value + 15 print("Money Given") elseif pizzatype.Value == 3 then money.Value = money.Value + 20 print("Money Given") end else print("no job") end end) end) end)
try elseif
workspace.Locations.GiveMoney.OnServerEvent:Connect(function() lplayer = script.Parent.Parent money = script.Parent.Parent.leaderstats.Money delivery = script.Parent.Parent.leaderstats.Deliveris okpizzajob = lplayer.Jobs.OKpizza if okpizzajob.Value == 1 then pizzatype = script.Parent.OKpizza.Job.Take.Pizza delivery.Value = delivery.Value + 1 wait(0.1) if pizzatype.Value == 1 then money.Value = money.Value + 10 end wait(0.1) elseif pizzatype.Value == 2 then money.Value = money.Value + 15 end wait(0.1) elseif pizzatype.Value == 3 then money.Value = money.Value + 20 end end end)
If you are using it on a local script, you need to either A: Switch to a server script B: Make a remote event to change it on the server C: (NOT RECOMMENDED) Turn off filtering enabled on workspace properties
BTW it is server script and all values are in player and line line 8 is checker if player is in job or no