✓ Accepted answer
MouseButton1Click does not take in any parameters. How I found that out was by going to GuiButton's wiki page and then looked for the MouseButton1Click event in the events section
Since you're using a local script, What you can instead do is get the player by saying:
local player = game.Players.LocalPlayer
Another issue with your script is that you can't view the server storage from the client. If you press play and look at the explorer, you'll see you can't see the contents of ServerStorage. You CAN see ReplicatedStorage though so if you'd like you can put the PlayersMoney/Copper Sword there instead.
You also can't change stat's value from the client. Aside from the player's movement, any changes you make to the game from the client won't change on the server, so you changing stat's Value will only show up for you, the change won't show up to anyone else on the server.
That is, unless you use remote events/remote functions
An example of your code with some changes:
#Local script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local stats = game.ReplicatedStorage.PlayerMoney:FindFirstChild(player.Name)
local tool = game.ReplicatedStorage:FindFirstChild("Copper Sword")
ReplicatedStorage.BuyItem:FireServer("Copper Sword")
end)
#Server Script:
game.ReplicatedStorage.BuyItem.OnServerEvent:Connect(function(player, item)
end)
What you need to do for this code to work is create a remote event called BuyItem and put it in the ReplicatedStorage. You also need to put your PlayerMoney and Copper Sword into the replicated storage too.
didn't explain remote functions in depth so if you need help with that let me know i can explain more in detail if youd like
2 comments
The MouseButton1Click event does not pass the player as an argument to the connected function. Define the player using the LocalPlayer property of the Players service.
https://developer.roblox.com/en-us/api-reference/property/Players/LocalPlayer