The last question was answered but how can be only one player can touched that part and not all players. I know that this script is for all players but can you help me to change it on only one player touches because if in the test in local server, it teleports all players when it touch the part. For more understandable, Example: There are 2 players namely Player1 and Player2. If the Player1 touches the part it teleports in the SpawnLocation in the Player1 but Player2 teleports too even Player2 did not touch the part.Can you help me? This is the script.
local plrs = game.Players:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do local player = plrs[i] local char = player.Character local stats = player:WaitForChild('stats') char.Head.CFrame = CFrame.new(workspace.MegaChallenge.Lobby.SpawnLocation.Position) stats:WaitForChild('Playing').Value = false stats:WaitForChild('Winners').Value = true
Can you change it? Thanks in advance if you answer that properly.
I mean, what you're trying to do here is completely wrong (to how I do it). What you would want to do is use MoveTo()
. MoveTo()
takes a model (in this case the player who touched the part) and moves it to the desired location. A basic script to do this would look like as follows:
script.Parent.Touched:Connect(function(hit) --Fires when the part is hit local Humanoid = hit.Parent:FindFirstChild("Humanoid") --Checks if Humanoid exists if Humanoid then --If Humanoid is true, and it will if it found the Humanoid Humanoid.Parent:MoveTo(partname.Position) --Like said above, this will move the player model to the part. end end)
I hope this helped!