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

Party system not function, why?

Asked by
BryanFehr 133
5 years ago

Hello, I am creating a battle royale game, but my lobby party teleport system isn't functioning! There's no error statements in the OutPut, and as far as I can see, nothing wrong with the script itself! It's placed in a LOCALSCRIPT inside the teleport part. Please help!

local Part = script.Parent
script.Parent.Touched:Connect(function(hit)
local tableOfParts = Part:GetTouchingParts()
local numberOfPlayers = 0
for i,v in pairs(tableOfParts) do
if v:FindFirstChild("Humanoid") then
numberOfPlayers = numberOfPlayers + 1
end
end
if numberOfPlayers == 2 then
for i,v in pairs(tableOfParts) do
if v:FindFirstChild("Humanoid") then
local plr 
game:GetService("Players"):GetPlayerFromCharacter(v)
game:GetService("TeleportService"):Teleport(2978237413,plr)
end
end
end
end)
0
omg use indents LoganboyInCO 150 — 5y

1 answer

Log in to vote
1
Answered by
blockmask 374 Moderation Voter
5 years ago

1) Please indent. 2) I'm assuming that localscript is in workspace, so simpy change that client-sided script into a server-sided scripted which will solve all your problems 3) TeleportService is known for having the most failed connections, so I'm suggesting you pcall the teleporting part and probably kick the player if it can't successfuly teleport the player.

0
Also, I didn't realize until now, but you're just checking and running that script ONCE, If :GetTouchingParts doesn't update automatically, then use a while true do loop blockmask 374 — 5y
0
^ Most of the code is in a .Touched event, so a while loop isn't necessary. Also, kicking the player when teleporting fails is probably not a good idea. Maybe retry or tell the user that the teleport has failed. User#20279 0 — 5y
0
Right, I didn't see the Touched event and you're correct about kicking the player if it has failed blockmask 374 — 5y
0
Sorry for lack of indentation, I still don't fully understand how to use the new Code blocks, lol. But thank you! BryanFehr 133 — 5y
0
No problem blockmask 374 — 5y
Ad

Answer this question