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

Party system not function, why?

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)

1 comment

0

omg use indents

1 answer

✓ Accepted answer
  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.

5 comments

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

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.

0

Right, I didn't see the Touched event and you're correct about kicking the player if it has failed

0

Sorry for lack of indentation, I still don't fully understand how to use the new Code blocks, lol. But thank you!

0

No problem

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