Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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)
0
have you told the server what plr is? AltNature 169 — 5y
0
Nevermind, I'm tired im being dumb. AltNature 169 — 5y
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 Vulkarin 581 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.

0
plr is referencing the index not the player objects themselves Vulkarin 581 — 5y
0
welp i guess im wrong. AltNature 169 — 5y
Ad

Answer this question