I am making a shop which is supposed to give an item. It doesn’t substract money so that doesn’t matter anymore, my issue is that the tools from replicatedstorage dont work when they are given. They only work in StarterPlayer. I already posted and I was told to make a RemoteEvent. I don’t have scripting knowledge so I tried doing this from a tutorial: Why does it not work? What do I have to change?
LocalScript on button:
-- Function to handle the purchase button click local function PeriastronClicked() local player = game.Players.LocalPlayer -- Get the player's leaderstats local leaderstats = player:WaitForChild("leaderstats") -- Get the player's money value local moneyValue = leaderstats:WaitForChild("Money") -- Check if the player has enough money to make the purchase if moneyValue.Value >= 5000 then -- Adjust the price of the item here -- Subtract the item price from the player's money moneyValue.Value = moneyValue.Value - 10 -- Adjust the price of the item here -- Give the item to the player local item = game.ReplicatedStorage.Items.RainbowPeriastron:Clone()-- item item.Parent = player.Backpack else -- Player doesn't have enough money, display an error message or take appropriate action print("Not enough money to purchase the item!") end end -- button name local Periastron = script.Parent -- Reference to the button itself -- Connect the button click event to the purchaseButtonClicked function Periastron.Activated:Connect(PeriastronClicked) game.ReplicatedStorage.Items.RemoteEvent:FireServer(PeriastronClicked) --ServerScriptService: game.ReplicatedStorage.RemoteEvent.OnserverEvent:Connect(function) end)