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

My script for making a gui visible when a specific player joins is not working, Anyone able to help?

As stated in the title, I've been attempting to create a script that would allow a GUI to become visible when a specific player joins the game, then becoming invisible shortly thereafter. The script I've made and used doesn't appear to have worked at all, and I'm a bit confused.

Here's my code.

function onPlayerEntered(newPlayer) 
 if (newPlayer.Name== "Jovelo") then
wait(2)
script.Parent = GUI
GUI.Visible = true
wait(10)
GUI.Visible = false

Anyone have any ideas?

4 comments

0

Do you want the GUI to be visible for everyone or only that player?

0

I'd like it to be visible for everyone, if possible.

0

for that, I think you'd need a remote event.

1

If I were you I would do that on client.

2 answers

You need to call the function with an event.

function onPlayerEntered(newPlayer)
if newPlayer.Name == "Jovelo" then
wait(2)
GUI = script.Parent
GUI.Visible = true
wait(10)
GUI.Visible = false
end
end

game.Players.PlayerAdded:Connect(onPlayerEntered)

Don't forget to accept the answer if I helped!

1 comment

0

So, I've implemented the script, and it still does not appear to be working, I've tried putting the screengui as a parent, as well as the textlabel, and neither of them elicit a response from the script.

You can fix this by using RemoteEvents.

Server Sided Script:

local Event = EventPart:WaitForChild("EventNameHere") -- Remote event

game.Players.PlayerAdded:Connect(function(Player)
	if Player.Name == "PlayerNameHere" then
		Event:FireAllClients()
	end
end)

Local Script, A child of the GUI:

local Event = EventPart:WaitForChild("EventNameHere") -- Remote event

Event.OnClientEvent:Connect(function() -- Listen to event 
	script.Parent.Visible = true
	wait(10)
	script.Parent.Visible = false
end)

This should work.

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