GUI meant for client shows for all players

  1. Hi, my intention is for the text label Gui to only show for the player whom collides with the part (in this instance, for the player wearing a “Skull”) however it shows for all players.


-- Local Script in the text label.

local Block = workspace.RespawnWarning
local plr = game.Players.LocalPlayer;
local ui = script.Parent;

	local Character = Part.Parent

	if Character == nil or Character:findFirstChild("Humanoid") == nil then return end

	local Head = Character:findFirstChild("Skull")

	if Head == nil then return end

	ui.Visible = true; 
	ui.Visible = false;

Is it a local script? A normal script will show for all players. While a local script only shows for the one person.

Yes, it’s a local script.

(char limit)

Maybe the script isn’t specific enough. All the players are listed during the game and they all are characters. Maybe you make it check the players name or something. Sorry if i sound dumb I’m a noob at scripting.

.Touched will trigger for any part that hits it (including other players characters), regardless of whether its local or not. A simple fix since you’re doing this locally is to check if the player that hit the part == the local player.

Just do something like:

local PS = game:GetService("Players");
local HitPlayer = PS:GetPlayerFromCharacter(Part.Parent);

if HitPlayer == PS.LocalPlayer then
-- continue logic

Might be typos so watchout

You must do this in a server script. Local scripts doesn’t help, you’ll also need remote events.

Wait never mind, its local script

Bump. (I’ve tried doing a singular client remote event to no avail)

-- Script in part

local player = game:GetService("Players").LocalPlayer
local remoteEvent = game.ReplicatedStorage.RemoteEvent
	remoteEvent:FireClient(player) -- :FireAllClients, it will show. Currently it does nothing.

-- Local Script in text label
local ui = script.Parent;

	ui.Visible = true

Perhaps its because when the block touches, it will fire for ALL players

Consider adding a condition statement checking if Part.Parent.Name==plr.Name then do the contents

else return.

As a side note, I suggest using zoneplusv2 module for more efficiency and utility but your choice:


Thank you, I’ll give this a shot.