Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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)

0
It doesn't return any arguments. :c http://wiki.roblox.com/index.php?title=MouseButton1Click TheeDeathCaster 2368 — 6y
0
Btw, maybe this's what you're looking for? c: http://wiki.roblox.com/index.php?title=LocalPlayer TheeDeathCaster 2368 — 6y

1 answer

Log in to vote
0
Answered by
FazNook 61
6 years ago

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!

Ad

Answer this question