It checks if a player has been moved into the storage and then moves them.
while true do wait(1) if game.ReplicatedStorage.Players.Check.Value == 3 then print("No Players Stored") elseif game.ReplicatedStorage.Players.Check.Value == 1 then print("Player Found") game.ReplicatedStorage.Players.Check.Value = 2 local Location = game.ReplicatedStorage.Players.Player:FindFirstChildOfClass("Part") Location.Parent = game.Workspace.Players print("Player Moved") game.ReplicatedStorage.Players.Check.Value = 3 elseif game.ReplicatedStorage.Players.Check.Value == 2 then print("Player Move In Progress") wait(2) end end
This script renames the part to the players name and then moves it to storage for the above script to move into the Workspace, This 2 step move has to be done as when the below script moves the part it stores it locally preventing players from seeing each other, This is also setting the value for when a part is in there, This is a Local Script.
wait(2) local Pos = game.Workspace.Spawn.Position local Player = script.Parent:Clone() local NM = script.Parent.Parent.NM.Value Player.Name = NM Player.Parent = game.ReplicatedStorage.Players.Player Player.Position = Pos game.ReplicatedStorage.Players.Check.Value = 1 print(NM, "Has been moved") wait(5) script.Parent.Parent.Parent.Controls.ControlMain.Disabled = false script.Parent.Parent.Parent.Camera.Camera.Disabled = false
Properly formatting/indenting code is good practice, as it allows for easier readability which in turn helps debugging. Allow me to help.
while true do wait(1) if game.ReplicatedStorage.Players.Check.Value == 3 then print("No Players Stored") else if game.ReplicatedStorage.Players.Check.Value == 1 then print("Player Found") game.ReplicatedStorage.Players.Check.Value = 2 local Location = game.ReplicatedStorage.Players.Player:FindFirstChildOfClass("Part") Location.Parent = game.Workspace.Players print("Player Moved") game.ReplicatedStorage.Players.Check.Value = 3 else if game.ReplicatedStorage.Players.Check.Value == 2 then print("Player Move In Progress") wait(2) end end end end
Now, it's much easier to spot what you did wrong:
else if
is not a keyword in Lua. Rather, use elseif
.
You added two extra end
s at the bottom.
Here's the fixed script.
while true do wait(1) if game.ReplicatedStorage.Players.Check.Value == 3 then print("No Players Stored") elseif game.ReplicatedStorage.Players.Check.Value == 1 then print("Player Found") game.ReplicatedStorage.Players.Check.Value = 2 local Location = game.ReplicatedStorage.Players.Player:FindFirstChildOfClass("Part") Location.Parent = game.Workspace.Players print("Player Moved") game.ReplicatedStorage.Players.Check.Value = 3 elseif game.ReplicatedStorage.Players.Check.Value == 2 then print("Player Move In Progress") wait(2) end end
Hope I helped!