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

How to get a player to change value using server script?

So I want to change a players value without using remote events or ontouched, any help? Here is the script.

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()

game.Workspace.CustomizationPartGui.SurfaceGui.FirstName.Alex.MouseButton1Click:connect (function ()
Player:WaitForChild("leaderstats").FirstName.Value = game.Workspace.CustomizationPartGui.SurfaceGui.FirstName.Alex.Text
end)

1 comment

0

You can only use LocalPlayer on the client

1 answer

You would have to separate the script with a localscript. You could have a localscript that is disabled as a child of the server script. The localscript will have a string value inside it. The localscript would change the value of the surface gui to the value of the string value.

The server script would clone the disabled localscript, change the stringvalue of the cloned instance, and place in the player you want to change. Then enable the localscript.

But in my opinion, it's much much easier to do this via localscript and not server.

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