Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

5 comments

0

You can use the Changed event.

0

or you can just set the Parent to another script.

0

I am very new to scripting can you send me an article about this? Or please explain how I could use this.

0

What do you mean set the parent to another script?

0

@krimsinTV , I posted an answer.

1 answer

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

3 comments

0

How would I put the int value in Local storage

0

*replicatedstorage

0

Just drag the IntValue to ReplicatedStorage.

This discussion is preserved as it was. New answers, comments, and votes are closed.