Hey everyone, a really big noob here. I'm trying to make a tool shop, and right now, I'm trying to make it so if a player clicks the button, the remote event fires and it picks up on another server script in serverscriptservice. Everything else is working except for the place where I reference the player in the script. Anyways, here are the scripts.
Working LocalScript
local buymedkitbutton = script.Parent
buymedkitbutton.MouseButton1Click:Connect(function()
game.ReplicatedStorage.BuyItem:FireServer()
end)
Not working Server Script in ServerScriptService
local buyitem_event = game.ReplicatedStorage.BuyItem
buyitem_event.OnServerEvent:Connect(function()
game.Players.PlayerAdded:Connect(function(player) -- this is the part that doesn't work. I'm thinking maybe that's not the proper way to reference someone's backpack in a server script?
print(player.Name.." has clicked.") -- this doesn't print
if player.leaderstats.Money.Value >= 200 then
local medkitclone = game.ReplicatedStorage.medkit:Clone()
medkitclone.Parent = player.Backpack
end
end)
end)
Also, everything might be wrong because this is how I think scripts and remote events work lol.
