If I run this script and click the open button, it does nothing. The clicked value is nil, how do I make the value of clicked the player? (I tested and printed the value of clicked which is nil) I want to make it so when the player clicks the open button, their cash decreases by 10.
local open = script.Parent
local frame = script.Parent.Parent
local closeframe = script.Parent.Parent.Parent.CloseFrame
open.MouseButton1Click:Connect(function(clicked)
if game.Players:GetPlayerFromCharacter(clicked) then
clicked.leaderstats.Cash.Value = clicked.leaderstats.Cash.Value - 10
closeframe.Visible = true
end
end)

1 comment
Clicked isn't a valid parameter for MouseButton1Click. Just use game.Players.LocalPlayer. This should be in a LocalScript anyways.