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.
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)
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