Filtering Enabled Teleport script Teleports all players?
So I just got done fixing all my Gui's from turning filtering enabled on. Now I'm not sure if this script breaking is a direct result of filtering enabled or if this has always been a problem. I just played my game with friends and when a player touches a brick it teleports all players besides just the one who touched the brick.
Here's what I think is the important part of my script.
1 | Part.Touched:connect( function () |
2 | local Spawn = game.Workspace.TeleportAndSpawnStorage.RandomFunRoomSpawn |
3 | for _, player in pairs (game.Players:GetPlayers()) do |
4 | local Torso = player.Character:WaitForChild( "Torso" ) |
5 | Torso.CFrame = CFrame.new(Spawn.Position + Vector 3. new( 0 , 2 , 0 )) |
However, because I have no clue what's wrong, here's the whole script.
01 | local Part = script.Parent |
02 | Part.Touched:connect( function () |
03 | local Spawn = game.Workspace.TeleportAndSpawnStorage.RandomFunRoomSpawn |
04 | for _, player in pairs (game.Players:GetPlayers()) do |
05 | local Torso = player.Character:WaitForChild( "Torso" ) |
06 | Torso.CFrame = CFrame.new(Spawn.Position + Vector 3. new( 0 , 2 , 0 )) |
08 | for _, player in pairs (game.Players:GetPlayers()) do |
09 | if player:FindFirstChild( "leaderstats" ) then |
10 | if player:FindFirstChild( "MemoryGameBeat" ).Value = = false then |
11 | player.leaderstats.RoundsBeaten.Value = player.leaderstats.RoundsBeaten.Value + 1 |
12 | player:FindFirstChild( "MemoryGameBeat" ).Value = true |
13 | player.leaderstats.Points.Value = player.leaderstats.Points.Value + 7 |
15 | if player:FindFirstChild( "Backpack" ) then |
16 | player.Backpack.RemoteClient.ChangeGui:FireClient(player) |
18 | player.PlayerSoundFolder.MemoryGameLevelOneWinnerSound:Play() |
20 | local Spawn = game.Workspace.TeleportAndSpawnStorage.TeleportSpawn |
21 | for _, player in pairs (game.Players:GetPlayers()) do |
22 | local Torso = player.Character:WaitForChild( "Torso" ) |
23 | Torso.CFrame = CFrame.new(Spawn.Position + Vector 3. new( 0 , 2 , 0 )) |
26 | player.PlayerSoundFolder.MemoryGameLevelOneWinnerSound:Stop() |
Now I'm sure this might not be the most clean script ever, but I really need help.
Would making this into a local script help maybe? It's just I have a teleport Gui that teleports all players too and that's a local script so I'm sorta stuck.