Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to make it so that two scripts can update one another ?

Asked by 4 years ago
Edited 4 years ago

first code: Location : part script type : script

script.Parent.ClickDetector.MouseClick:Connect(function(player)
player.leaderstats.Crops.Value = player.leaderstats.Crops.Value + 2
end)

outcome : Player.Leaderstats.Crops.Value = 2

second code: Location : tool Script type : Local Script

script.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
    player.leaderstats.Crops.Value = player.leaderstats.Crops.Value - 1

end)
end)

outcome : Player.Leaderstats.Crops.Value = 1

but when I clicked the part that has my first code again , the oucome is 4 instead of 3 How do I fix this , plz help me

1
not a site to give name ideas Gameplayer365247v2 1055 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Part of your code is running on the server, and part of your code is running on the client. The client is not allowed to make changes directly to the server, so anything a local script does will not be seen by your server script. Remote events will be necessary in order for the tool to be able to make changes for the int value.

More literature is available about the Client-Server Model and using Remote Events/Functions on the developer website.

The developer wiki will be your best friend as you learn to script.

Ad

Answer this question