Server script only affecting one client

Hi. I am working on a sword fight minigame. I was editing my scripts and getting everything ready, but then i realized while testing using the Local Server feature: The script was only affecting one client. Whenever a client clicks the button, all clients will go to the CFrame, but for some reason only the one that clicked it gets moved. Here is the script.

-local Sword = game.ReplicatedStorage:WaitForChild(“Sword”):Clone()
local Players = game:GetService(“Players”)
local Timer =“IntValue”)
Timer.Name = “Timer”
Timer.Parent = game.ReplicatedStorage
local Start = game.Workspace.Start
Sword.Parent = Player:WaitForChild(“Backpack”)
Player.Character.HumanoidRootPart.Position = game.Workspace.TPart.CFrame.Position

	print("Sword Fight has started.")
	Timer.Value = 10
	while Timer.Value >= 0 do
		print("Seconds remaining: " .. Timer.Value)
	Timer.Value = Timer.Value - 1
	if Timer.Value == 0 then


You need it to be a client-server-client set up or to find the rest of the players. Right now your script receives data from the client who clicked it, which means its the only player name that will get sent. If you want it to teleport everyone, you’ll need to get children from the playerservice and loop through the table of users, teleporting them each time.

I think the best strategy for this is to make it a ready-up system. Your client clicks a button which tells the server that the player is ready to teleport. When the leader client sends the start signal, that will then activate the teleport function, mind you that it will still need to loop through the list to successfully teleport everyone.

Inside the function in the clicked event, you’re changing the position of only the player that clicked the button. I would do

for i,v in pairs(Players:GetPlayers()) do
    v.Character.HumanoidRootPart.Position = workspace.TPart.Position

instead of

1 Like