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)
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!