script.Parent.MouseButton1Click:connect(function(playerwhi)
	  playerwhi = playerwhi.Name
    game.Players:FindFirstChild(playerwhi).leaderstats.Money.Value = game.Players:FindFirstChild(playerwhi).leaderstats.Money.Value - 100
end)
  

That is a buy script I have been working on and I don't know why it wont work this is the error message 14:29:40.255 - Players.Player.PlayerGui.ScreenGui.Frame.TextButton.Buy:2: attempt to index local 'playerwhi' (a nil value)

2 comments

0

The MouseButton1Click event does not return a player value. Try playerwhi = script.Parent.Parent.Parent.Parent.Parent.Parent (Hoping I counted the parents correctly, would use LocalPlayer if I knew for sure it was a LocalScript).

0

Thanks!