So I was testing the teleport script I had in my game with my friend. It is activated once a .Touched event is pressed. But, when I read the documentation, it should only teleport the local player. Instead, it teleports the whole server to one place.
The script is laying in StarterGui, and it is activated once a part has been touched by a player in the workspace. The script is a LocalScript.
The reason it happens if because you need to verify if the person who touched the part, this is because everyone has that localscript for the touched event, so if a single person touches the part, everyone will be affected as there’s no verification. You need to verify the person who touched, something like this should work
local player = game:GetService("Players").LocalPlayer
teleport1.Touched:Connect(function(hit)
if player.Character and hit:IsDescendantOf(player.Character) then
TeleportScreen2.Parent = PlayerGui
TeleportService:Teleport(gameId1)
end
end)
It checks if the localplayer’s character exists and if they do exist, check if the hit part is a descendant of their character, and if it is, teleport