I'm trying to make a game where you can buy a sword w/ the starting cash from some leaderstats. If I put the sword into Starterpack, it works fine. However, once I purchase the sword and it goes into my inventory, it seems to just break the scripts. Here is my current script:
script.Parent.MouseButton1Click:Connect(function()
local PriceOfItem = game.ReplicatedStorage.Buyables.Sword.Price.Value
if game.Players.LocalPlayer.leaderstats.Cash.Value >= PriceOfItem then
local clone = game.ReplicatedStorage.Buyables.Sword:Clone()
clone.Parent = game.Players.LocalPlayer.Backpack
game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - 50
end
end)
P.S. This is in a LocalScript in a textbutton in a Gui. If you're wondering about the "Buyables" section, it's a folder in ReplicatedStorage.

3 comments
Just realized I didn't put the whole thing in a code block. Extremely apologetic, can I edit the post?
How is a local script going to get to the server?
That wouldn't work with FE