Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

does anyone know how to make a gui only show for a certain player?

i was playing with my friend and he got to the gui part and it showed up for him and me aswell. so i need to figure out how to make it so it only shows for the player that triggered the gui


workspace.WishHimAGoodBirthday.ClickDetector.MouseClick:Connect(function() script.Parent.TextTransparency = 0.9 wait(.03) script.Parent.TextTransparency = 0.8 wait(.03) script.Parent.TextTransparency = 0.7 wait(.03) script.Parent.TextTransparency = 0.6 wait(.03) script.Parent.TextTransparency = 0.5 wait(.03) script.Parent.TextTransparency = 0.4 wait(.03) script.Parent.TextTransparency = 0.3 wait(.03) script.Parent.TextTransparency = 0.2 wait(.03) script.Parent.TextTransparency = 0.1 wait(.03) script.Parent.TextTransparency = 0.0 end)

1 answer

✓ Accepted answer

You're going to need 2 scripts and a RemoteEvent (put the RemoteEvent in the ReplicatedStorage)

Server script (put this in the server script service)

local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local playerId = 000000 -- make this the UserId of the player that you want to see the GUI

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if player.UserId == playerId then
			event:FireClient(player)
		end
	end)
end)

Local script (put this in the TextLabel or whatever is inside the ScreenGui)

-- localscript
local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local gui = script.Parent.Parent -- the ScreenGui object.
gui.Enabled = false -- make everything that is part of ScreenGui invisible.

event.OnClientEvent:Connect(function()
	gui.Enabled = true
end)

Make sure to change these variables to actually match what they are in your game (playerId, gui location, etc).

Hope this helps!

EDIT: In response to you're comment:

Server script (ServerScriptService):

local endPart = workspace:WaitForChild("EndPart")
local event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

endPart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		event:FireClient(player)
	end
end)

The LocalScript should stay as it is.

2 comments

0

i am trying to make it so if one person gets to the end then they see the gui not the other players and if i do it by user id then that one use id is going to be the only person that is able to see the gui

0

Hi, I just edited the answer so hopefully it helps you.

This discussion is preserved as it was. New answers, comments, and votes are closed.