Teleporter teleports all players at once, even if it's supposed to teleport only one player!

So I made portals that teleport you to a specific location on the map, and for some reason it teleports all of the players in the server. It also teleports everyone when a different object that has a humanoid in it touches the portal.

All of the scripts are local scripts in starterGui, and the portals are in a model inside of the workspace.

Here are the scripts:

Portal 1:

game.Workspace.Zone4.SansCatPortal.Portal1.Main.Touched:Connect(function()
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Workspace.Zone4.SansCatPortal.Portal2.Main.CFrame - Vector3.new(0,0,8)
end)

Portal 2:

game.Workspace.Zone4.SansCatPortal.Portal2.Main.Touched:Connect(function()
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Workspace.Zone4.SansCatPortal.Portal1.Main.CFrame + Vector3.new(0,0,8)
end)

It also seems to happen on a portal that only teleports players with a gamepass:

Portal 1:

local M = game:GetService("MarketplaceService")
local GamepassID = 17768668
game.Workspace.Zone4.VIPPortal.Portal1.Main.Touched:Connect(function()
	if M:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId,GamepassID) then
		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Workspace.Zone4.VIPPortal.Portal2.Main.CFrame + Vector3.new(0,0,8)
	else
		
	end
end)

Portal 2:

game.Workspace.Zone4.VIPPortal.Portal2.Main.Touched:Connect(function()
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Workspace.Zone4.VIPPortal.Portal1.Main.CFrame + Vector3.new(0,0,8)
end)

If anyone can help, I’d appreciate that!

1 Like

See this tutorial which describes the issue very well with touched events on the client.

3 Likes

Anything touched the part will fire this and because of all the clients have this localscript it teleports them

1 Like

do something like this

game.Workspace.Zone4.VIPPortal.Portal2.Main.Touched:Connect(function(hit)
if hit.Parent == game.Players.LocalPlayer.Character then
	game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Workspace.Zone4.VIPPortal.Portal1.Main.CFrame + Vector3.new(0,0,8)
end
end)

Everyone had mention the correct answer that you need to verify touches when they’re client sided or in general, any client sided event unrelated to Guis, such as a ProximityPrompt’s Triggered event which will also need verification, but I want to address something with this script

local M = game:GetService("MarketplaceService")
local GamepassID = 17768668
game.Workspace.Zone4.VIPPortal.Portal1.Main.Touched:Connect(function()
	if M:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId,GamepassID) then
		game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = game.Workspace.Zone4.VIPPortal.Portal2.Main.CFrame + Vector3.new(0,0,8)
	else
		
	end
end)

There’s really no need to do it like this if it’s client sided, because even players who don’t have the gamepass will have the event made for them, check if they have the gamepass first before making the touched event

local M = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local GamepassID = 17768668

if M:UserOwnsGamePassAsync(Players.LocalPlayer.UserId,GamepassID) then
	workspace.Zone4.VIPPortal.Portal1.Main.Touched:Connect(function()
		Players.LocalPlayer.Character.HumanoidRootPart.CFrame = workspace.Zone4.VIPPortal.Portal2.Main.CFrame + Vector3.new(0,0,8)
	end)
end

And I recommend moving the scripts somewhere where the events will only be made once, such as StarterPlayerScripts, as anything in StarterGui, including Localscripts, will be replicated on respawn, so it’ll recreate the events again which could add up over time as they wont overwrite each other I believe

2 Likes

I’m gonna try that! Hope it works!

It worked, thank you! :slight_smile: