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

Teleporting a specific player?

So I am now having trouble with the teleporting part for the other players. It teleports the sniper fine. But won't teleport the other players

Gives me this error: "Torso is not a valid member of Player, Line 44 (Or in this post, line 16)

local players = game.Players:GetChildren()

    print(#players)


 if #players >= 2 then

        local sniper = players[math.random(1,#players)]
    local chosenName = sniper.Name
        local weapon = game.Lighting.Sniper
        weapon.Parent = sniper.Backpack
    sniper.Character.Torso.CFrame = game.Workspace:FindFirstChild("SniperPosition").CFrame * CFrame.new(0,1,0)

    for i,v in pars(players) do
        if v.Name ~= chosenName then
            v.Torso = game.Workspace:FindFirstChild("PlayerPosition").CFrame * CFrame.new(0,1,0) -- This part.
        end
    end


1 answer

✓ Accepted answer

Basically all you have to do is make a variable and define it as the name of the player. After doing this you can teleport the rest. So in the condition on line 29 add the following

local players = game.Players:GetChildren() --Part I need help with.

    print(#players)

  
 if #players >= 2 then
       
        local sniper = players[math.random(1,#players)]
	local chosenName = sniper.Name
        local weapon = game.Lighting.Sniper
        weapon.Parent = sniper.Backpack
	sniper.Character.Torso.CFrame = game.Workspace:FindFirstChild(ItemHere).CFrame * CFrame.new(0,1,0)

	for i,v in pars(players) do
		if v.Name ~= chosenName then
			v.Torso = game.Workspace:FindFirstChild(ItemHere).CFrame * CFrame.new(0,1,0)

		end
    end

This script should teleport the players without the name of the chosen sniper

~~Hope i helped

1 comment

0

Hmmm I did that but now it is saying "Argument 1 missing or nil, Line 39 I put in the name of the brick where I wanted them to teleport to so I'm not sure whats up.

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