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

How would I move a variable form a localscript to a server script?

Asked by 4 years ago

I need to move a int value from a local script to a server script how would I accomplish this what method should I use what is the cleanest and fastest one I have tried global but it isn't working.

0
You can use the Changed event. Dovydas1118 1495 — 4y
0
or you can just set the Parent to another script. Dovydas1118 1495 — 4y
0
I am very new to scripting can you send me an article about this? Or please explain how I could use this. krimsinTV -5 — 4y
0
What do you mean set the parent to another script? krimsinTV -5 — 4y
0
@krimsinTV , I posted an answer. Dovydas1118 1495 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

There's 2 ways you can do it. I'll show you the easiest way. Put the IntValue in ReplicatedStorage instead of making it inside a local script. You can the IntValue.Changed event (or GetPropertyChangedSignal()) to initiate values within a local script.

game.ReplicatedStorage.IntValue.Changed:Connect(function()
    --Do stuff
end)

Another way is just setting the parent. I would not recommend doing this except for leaderstats and GUIs. But it should work. Setting the parent is another of saying: move from one place to another.

--Script
local intValue = game.Workspace.Script.IntValue

intValue.Parent = game.Workspace.LocalScript
0
How would I put the int value in Local storage krimsinTV -5 — 4y
0
*replicatedstorage krimsinTV -5 — 4y
0
Just drag the IntValue to ReplicatedStorage. Dovydas1118 1495 — 4y
Ad

Answer this question