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

This script won't clone the Gui into the player?

script.Parent.Click.MouseButton1Click:connect(function(player)
	local gui = script.Prompt:Clone()
	gui.Main.Disabled = false
	gui.Parent = player.PlayerGui
end)

This is a server script inside a button that is inside a surface gui.

Whenever I try to click the button that is supposed to clone the gui into my player it gives me an error shown below. Any help would be appreciated, thanks!

Workspace.Jukebox.Screen.SurfaceGui.Background.Script:4: attempt to index local 'player' (a nil value)

2 comments

0
0

Btw, maybe this's what you're looking for? c: http://wiki.roblox.com/index.php?title=LocalPlayer

1 answer

So what you were trying to do here was setting the argument of MouseButton1Click as "Player". The fact is that MouseButton1Click does not actually find the player who clicked it and its argument has no value (nil). None of the Mouse functions do but MouseButton1Down brings up the numerical value of where the player has clicked on the button. Since this is a gui, you can try the following:

Local Script inside the Gui

script.Parent.Click.MouseButton1Click:connect(function()
    local player = game.Players.LocalPlayer
    local gui = script.Prompt:Clone()
    gui.Main.Disabled = false
    gui.Parent = player.PlayerGui
end)

Thank you!

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