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;
Block.Touched:connect(function(Part)
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;
wait(5)
ui.Visible = false;
end)
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
end;
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
script.Parent.Touched:Connect(function()
remoteEvent:FireClient(player) -- :FireAllClients, it will show. Currently it does nothing.
end)
-- Local Script in text label
local ui = script.Parent;
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
ui.Visible = true
end)