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

Does we need a "For player " thing to make work a teleporter ?

I try to make it work, but nothing work when i try other script! The problem is when i join the console start to spam ' Workspace.Parkour1.Finish.Script:3: attempt to index local 'plr' (a number value) ' can someone help me on this !

script.Parent.Touched:Connect(function()
	for plr in ipairs(game.Players:GetChildren()) do
		plr.Character.LowerTorso.CFrame = CFrame.new(workspace.Lobby.TeleportFinishedParkour)
	end
end)

3 comments

0

have you told the server what plr is?

0

Nevermind, I'm tired im being dumb.

0

plr is referencing the index, you need to do for _,plr in pairs(game.Players:GetChildren())...combine that with the error incapaz found and it will work fine

1 answer

###This is because of line 3. You're attempting to set an object as a CFrame. This will throw an error.

local lobbyTP = game.Workspace.Lobby.TeleportFinishedParkour

script.Parent.Touched:Connect(function(part)
    for _, plr in ipairs(game:GetService("Players"):GetPlayers()) do
        plr.Character:SetPrimaryPartCFrame(lobbyTP.CFrame)
    end
end)

###I also set the CFrame to the PrimaryPart, to prevent any errors with R6. Also, I used GetPlayers instead of GetChildren as the latter will error if something other than a Player object is in there.

###Edit: plr is actually the index according to Vulkarin.

2 comments

0

plr is referencing the index not the player objects themselves

0

welp i guess im wrong.

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