Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the gear only on my screen?

Asked by 2 years ago

So I have this shop and the gear is only on my screen my friend showed me a screenshot and every gear given to me is only on my screen and on his end it's just me holding my arm out with nothing in my hand.

Here is the code -

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    if player.leaderstats.Coins.Value >= 1000 then
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 1000
        local clonar = game.ReplicatedStorage.SpeedCoil:Clone()
        clonar.Parent = player.Backpack
    end
end)

any help would be appreciated!

0
If this is a local script, then all of this will only be on the client. To fix this, you probably should use a remote event / function echobloxia 21 — 2y
0
This can be a client/local script which runs client-sided (only for one device). You can use a remote event AProgrammR 398 — 2y

1 answer

Log in to vote
0
Answered by
SuperPuiu 497 Moderation Voter
2 years ago

Make a script that will be in ServerScriptService and a RemoteEvent called "Buy"

local script:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    if player.leaderstats.Coins.Value >= 1000 then
        player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 1000
        game.ReplicatedStorage.Buy:FireServer(game.ReplicatedStorage.SpeedCoil)
    end
end)

Script:

game.ReplicatedStorage.Buy.OnServerEvent:Connect(function(Player, Item)
Item:Clone().Parent = Player.Backpack
end)
Ad

Answer this question