GUI enables for all players

For some reason, when a player touches the part that needs to be touched, the gui enables for everyone instead of only the player who touched the part, i hope anyone can help
Script (Inside Of StarterGUI and is a LocalScript) :

local player = game.Players.LocalPlayer
local playerGUI = player.PlayerGui
local frame = playerGUI.BlackScreen.ActualBlackScreen
local BlackScreen = playerGUI.BlackScreen
local char = player.Character
local HumanoidRootPart = char:FindFirstChild("HumanoidRootPart")
local playerGUI = player.PlayerGui




game.Workspace.PartQuiTeFaitTP.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		playerGUI.TpConfirmGUI.Enabled =true
	end
end)

Try using a FireClient() with a remote event

You are checking if any player touches the part before showing the gui. You need to check if the player touching it is the local player.

if hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) == player then
1 Like

Make RemoteEvent Called ShowGui in ReplicatedStorage.
Script in part:

local Part = script.Parent
local DB = true
Part.Touched:Connect(function(hit)
 local hum = hit.Parent:FindFirstChild("Humanoid")
 if hum and DB then
   DB = false
   game.ReplicatedStorage.ShowGui:FireAllClient()
    wait()
   DB = true
  end
end)

Put LocalScript in StarterGui
Code:

game.ReplicatedStorage.ShowGui.OnClientEvent:Connect(function()
 game.Players.LocalPlayer.PlayerGui:FindFirstChild("GUINAMEHERE").Enabled = true
end)

It works, thank you alot i won’t be making the same mistake again.

1 Like