✓ Accepted answer
It may be because the swords also apply damage (and sometimes add creator tags) on the server-side. This means that since you are adding the sword from the client (using a LocalScript), on the server-side, the sword was never added to the player's backpack. You can make this work by using a RemoteEvent and firing it from the LocalScript, having the signal be received by a server script. You can put the RemoteEvent in the same location as the scripts, in ServerStorage, etc.
So the LocalScript should look something like this:
local ReqGold = 10
local AvGold = game.Players.LocalPlayer.leaderboard.Gold
local RemoteEvent = script.Parent.RemoteEvent
local player = game:GetService("Players").LocalPlayer
function Buy()
if AvGold.Value >= ReqGold then
AvGold.Value = math.abs(AvGold.Value - ReqGold)
RemoteEvent:FireServer()
end
end
script.Parent.MouseButton1Click:Connect(Buy)
And the server script should look something like this:
local RS = game.ReplicatedStorage.swords
local IFS = RS.BronzeSword
local RemoteEvent = script.Parent.RemoteEvent
RemoteEvent.OnServerEvent:Connect(function(player)
IFS:Clone().Parent = player.Backpack
end)
If there are any problems with these scripts, please let me know as I would be happy to help. Also, if you don't understand something about the scripts or my explanation please let me know so I can help you understand. Using code that you don't understand will never help you learn.
2 comments
Thanks so much
You jerk, you should be accepting his answer if it helped, I'll just do it, you are missing out on +2 reputation points, now they're mine