Hello. This should be a script to purchase a particular item through ProximityPrompt. The problem arises when I have to add a "player" variable to the path to take a certain amount of money from the player. It needs to work in "Script", not "LocalScript", so I need something like ".LocalPlayer" *mode for *"Script". I hope you understand the problem.
Error:
Workspace.ropebuy.Script:10: invalid argument #2 (string expected, got Instance). Error mark firsts "if" line as a problem.
Thanks.
local price = 200 script.Parent.item.ProximityPrompt.Triggered:Connect(function(player) if game.Players[player].Backpack.Money.Value >= price then game.Players[player].Backpack.Money.Value = game.Players[player].Backpack.Money.Value - price print("Buyed") end if game.Players[player].Backpack.Money.Value < price then script.Parent.error:Play() print("No money") end end)
I got this error the fix for it is the following:
game.Players[player.Name] -- instead of: game.Players[player]
You're only getting the player's instance instead of the Name. Just like what @echobloxia said in the comments. Try doing game.Players[player.Name] instead of just game.Players[player]