so i made a script that when you touch the TeleportBrick you get teleported, but every time i did that every player in the server gets teleported too, can you guys fix my code?
local StarterGui = game:GetService("StarterGui")
local Gui = script.Parent
local Screen = Gui.Screen
local Camera = workspace.CurrentCamera
local Detect = workspace.TeleportBrick
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Detect.Touched:Connect(function(Hit)
local HitModel = Hit:FindFirstAncestorWhichIsA("Model")
if HitModel then
if HitModel == Character then
Screen.Autozoom.Disabled = true
Screen.ResetOnSpawn = false
Screen.UnEquipScript.Disabled = false
Screen.ButtonFrame.Play.ingame["ingame"].Disabled = true
Gui.VotingGui.JumpEvent:FireServer()
Gui.EmoteGui.OpenGui.Disabled = true
Gui.EmoteGui.ToggleButton.Visible = false
Screen.Enabled = true
Screen.Camera1.Disabled = false
Gui.HealthBarGui.Frame.Visible = false
Gui.MobileDashGui.Enabled = false
coreCall('SetCore', 'ResetButtonCallback', false)
workspace.Teleport2.RemoteFunction2:InvokeServer()
Humanoid:UnequipTools()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
Camera.CameraType = Enum.CameraType.Custom
end
end
end)
This is because you’re checking if the “something” which triggered the “Touched” event to fire on the BasePart instance has a “Humanoid” instance inside of it.
Instead you need to check if the “something” which triggered the “Touched” event to fire is the local player’s character for which the client-side script is running for.