I have made a script where when you click a part, a GUI is cloned to a GUI in the PlayerGui of the player.
The problem is that I get the error: “attempt to call a nil value”.
How do I fix this error?
Script:
game.Players.PlayerAdded:Connect(function(plr)
function onClick(click)
local ItemGui = game.ReplicatedStorage.Gui:Clone()
ItemGui.Frame.Name.Text = "Name"
ItemGui.Frame.Price.Text = "Price"
ItemGui.Frame.Description.Text = "Description"
ItemGui.Parent = plr.PlayerGui.GuiHolder
end
end)
script.Parent.ClickDetector.MouseClick:connect(onClick)