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

How I can transfer local value to Current Server ?

Example: I have a skill menu where you can increase lives or strength, the values I have stored in the game.Players.LocalPlayer.attrib When a local player presses the gui button, only he sees the value, and the current server shows 0, how can I change this?

1 answer

✓ Accepted answer

You need Remote Events to do that, put one of those in the replicatedstorage. Afterwards you should put this inside of your mousebutton1click thing :

local Stat = script.Parent.Text -- Write this if you put the script inside the button and you wrote your stat name in as text
local Remote = game.ReplicatedStorage:WaitForChild(“UpgradeStat”) -- Name the remote whatever you want to
Remote:FireServer(Stat)

That was done, you need to write the script(Put the script inside of the serverscriptservice) that’s gonna check when you fire the Remote :

local Remote = game.ReplicatedStorage:WaitForChild(“UpgradeStat”) -- Our variable

Remote.OnServerEvent:Connect(function(Player,Stat) -- When our remote is fired
      if not Player.attrib:FindFirstChild(Stat) then return end -- checks if the stat exists remove if you want
      Player.attrib:FindFirstChild(Stat).Value = Player.attrib:FindFirstChild(Stat) + 1
end)

Is this what you wanted?

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