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

Changes made to player aren't visible to others?

Asked by 4 years ago

so i made a character customization gui and put it on a local script in starter gui : local Pants1 = game.Players.LocalPlayer.Character:WaitForChild('Pants') script.Parent.Parent.MouseButton1Down:Connect(function() Pants1.PantsTemplate ='http://www.roblox.com/asset/?id=157717721' it works but the others cant see that change nor i can see theirs , any solutions Please?

0
Use a server script, local scripts only run on one's client, a server script will ensure replication to all clients Fad99 286 — 4y
0
You can do 2 things: Put it into a server sided script or use remote events. Sonnenroboter 336 — 4y

1 answer

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

So you've just encountered a problem with

Remote Events

What Are Remote Events And Functions?

Remote Events And Functions are a way for the Client to Communicate withe the Server.

The Client is the stuff on your screen any changes made with a LocalScript can only be seen on your screen, However if the changes were made with a Server Script Everyone will see the change on their screen instead of you alone, but it has to be in the a location of the game that can interact with the Server aka Not your player. A good location to put Server Scripts is the ServerScriptsService

How Do I Use Them?

Now what you want to do is create a local script somewhere within places that have something to do with the Client For ex lets say I put mine in the StarterCharacterScripts and I want to fire and event to communicate with the Server so not only will I see it everyone will

For this example ill be creating a part when i press a key

Local Script

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent") game:GetService("UserInputService").InputBegan:Connect(functionKey, IsChatting) if key.KeyCode == Enum.KeyCode.R and not IsChatting then Event:FireServer(key.KeyCode) end end)

Server Script

loca event == instance.new("RemoteEvent")
event.Parent = game.ReplicatedStorage
event.OnServerEvent:Connect(function(Player, Arg) --So you can send over arguements(Pieces of data that you want the Server to recieve, but keep in mind the Player is always the 1st Argument
    print(Arg) -- Arg in this case would be the Key.KeyCode fired in the parameter of the local script 
    local part == instance.new("Part")
    part.Anchored = true
    part.CFrame = Player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5)
    part.Parent = game.Workspace
end)

So when you press R a brick will Tell the Client to send information to the Server to create the brick

Also the Events Can go to the Client from the Server but thats another story https://developer.roblox.com/articles/Remote-Functions-and-Events

Ad

Answer this question