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

(ANSWERED) How come I can't access the PlayerGui?

#Introduction Hello there, I am having a problem with the PlayerGui property of the player. I am trying to access the player's PlayerGui, but it will not work.

My script:

function myFunction(player)
	local part = workspace.Part
	local clone = part.GUI:Clone()
	clone.Parent = player.PlayerGui
end
myFunction()

#Conclusion Can somebody help me?

2 comments

0

You aren't passing any variables when you call the function. It has no ideas what "player" is.

0

How can I describe "player...?"

1 answer

✓ Accepted answer

If you are using a local script to do this, you can find the player by using game.Players.LocalPlayer, and use the example below.

function myFunction(player)
    local part = workspace.Part
    local clone = part.GUI:Clone()
    clone.Parent = player.PlayerGui
end
myFunction(game.Players.LocalPlayer)

If this is a server script, you need to get another way to find that player. If that is the case, please write a response saying what you need to happen to have the function happen. From there, I can help you further.

2 comments

0

Let me try it...

0

Thanks a bunch!

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