How do I locate a player in a Server Script, and get this to work?
script.Parent.MouseButton1Click:connect(function(player) script.Parent.Parent.Parent.Parent.Parent.Parent.Collect.MoneyValue.Value = 0 script.Parent.TextLabel.Text ="Money:"..script.Parent.Parent.Parent.Parent.Parent.MoneyValue.Value local stats = player:FindFirstChild("leaderstats") stats.Money.Value = stats.Money.Value + script.Parent.Parent.Parent.Parent.MoneyValue.Value end)
I switched its order so its should work fine now. YOu kept changing the value to zero before anything could be done to it.
local collect = script.Parent.Parent.Parent.Parent.Parent.Parent.Collect local gui = script.Parent script.Parent.MouseClick:connect(function(player) local stats = player:FindFirstChild("leaderstats") gui.TextLabel.Text = "Money: "..collect.MoneyValue.Value stats.Money.Value = stats.Money.Value + collect.MoneyValue.Value collect.MoneyValue.Value = 0 end)
To reference a player in server script (im not sure this is the best way but it works regardless)
wait(1) for _,v in pairs (game.Players:GetChildren()) do print(v.Name) --would print your name end