Hi there, I am creating a game that will give players a value "mins". I want to transfer this value to another script so that when the player has enough "mins", they can walk into a door and be teleported to another section of the game. How can I transfer this variable across from one script in the workspace to another script inside a part? Thanks a lot! (I'm happy to clarify if you aren't 100% on the question)
Remote events,
Instructions:
create a remote event in replicated storage, set its name to "RemoteEvent" then, learn from these scripts:
localscript in startergui
1 | local value 1 = 500 |
2 |
3 | game.ReplicatedStorage.RemoteEvent:FireServer(value 1 ) |
Above, value1 is being sent to whatever is received on the other end of the remote.
regular script in workspace
1 | game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect( function (p,value 1 )) |
2 | -- parameters can be named anything but when transfering values, "p" will always be the player, its by default the first value. |
3 | print (value 1 ) |
4 | end ) |
Make sure that you use this method except use "mins" as value1 Hope this helped