Local is affecting all players?

So im trying to make it to were when people get to a certain point in my game they touch a block and a gui pops up to teleport them to another place within the place, the problem is when i touch the block other people that haven’t made it that far yet see there gui as well, the script is a local script in starter character.The gui is a gui in starter gui its enabled is false

local plyr = game.Players.LocalPlayer

local bossbattles = {“4145828571”}
local tps = game:GetService(“TeleportService”)
local ss = game.Workspace.SaveSpots
local b1 = ss:findFirstChild(“7”)

b1.Touched:connect(function(hit)
local thegui = plyr.PlayerGui:findFirstChild(“FirstBossGui”)
thegui.Enabled = true
local gb = thegui.Now
gb.MouseButton1Click:connect(function()
tps:Teleport(bossbattles[1],plyr)
end)

end)

I made a tutorial about this very problem some time ago. The issue is that you aren’t checking to see if the touched part is a descendant of the LocalPlayer’s character.

2 Likes

you need to check if the player touching it is the local player just do this. Also, you should 'nt have the mouseButton1Down event connection in the touched event connection

local PlayersService = game:GetService("PlayersService")
local plyr = game.Players.LocalPlayer

local bossbattles = {“4145828571”}
local tps = game:GetService(“TeleportService”)
local ss = game.Workspace.SaveSpots
local b1 = ss:findFirstChild(“7”)
local thegui = plyr.PlayerGui:findFirstChild(“FirstBossGui”)
local gb = thegui.Now

gb.MouseButton1Click:connect(function()
    tps:Teleport(bossbattles[1],plyr)
end)

b1.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if plyr == PlayersService:GetPlayerFromCharacter(hit.Parent) then
            thegui.Enabled = true
        end
    end
end)
4 Likes

Much thanks guys can I make you both the solution?

@ScriptingSupport post only fixed your touched issue. I fixed both the touched and mouse event issue. His post isn’t really fixing your code fully.