I have a shop using an in game currency to buy different tools. Buying the tools with the currency works but the tools are not functional. The tools are stored in ReplicatedStorage.
repeat wait()
Player = game.Players.LocalPlayer
Button = script.Parent
Item = game.ReplicatedStorage:FindFirstChild("Sword")
Cost = 1000
Coins = game.Players.LocalPlayer.leaderstats:FindFirstChild("Tix")
until
Button.MouseButton1Click:Connect(function(purchase)
if Coins.Value > (Cost - 1) then
Coins.Value = Coins.Value - Cost
local a = Item:Clone()
a.Parent = Player.Backpack
local b = Item:Clone()
b.Parent = Player.StarterGear
end
end)
What do you mean by “not functional.” Do you mean the tools themselves don’t work, or that they are not getting cloned into the player. Also is the a local script or a server script?
The tools that you are cloning don’t work because they are being cloned from a local script. This means that they will only appear for you, on your screen, and they will be nonexistant from the perspective of other players and the server. If the server doesn’t think it exists, then it can’t run the code inside of the tool.
You also probably shouldn’t be handling the shop on local scripts. Make a remote event in replicated storage and fire the event from the local script with event:FireServer(). Then, use event.OnServerEvent on a script to know when the event has been fired.
what the user @happya_x said is correct if a local script clones a tool which works with the server will not run because the server does not detect the change, it must communicate with the server and thus clone the tool @DasKairo that this in replicated storage has nothing to do