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

Help with buying weapon only works in studio mode?

Asked by
FiredDusk 1466 Moderation Voter
7 years ago

The buy script below only works in studio mode ;( I get no errors.

Price = 5
Player = game.Players.LocalPlayer
local SpeedCoil = game.ServerStorage.Weapons.SpeedCoil
local Taken = SpeedCoil.Taken

script.Parent.MouseButton1Click:connect(function()
    if Player:FindFirstChild("leaderstats") and Player.leaderstats["Gold bars"].Value >= Price then
        if Taken.Value == false then
            Player.leaderstats["Gold bars"].Value = Player.leaderstats["Gold bars"].Value - Price
            SpeedCoil:Clone().Parent = Player.Backpack
            SpeedCoil:Clone().Parent = Player.StarterGear
            Taken.Value = true
        end
    end
end)

1 answer

Log in to vote
1
Answered by 7 years ago

You can't access ServerStorage through Local scripts. Change it to replicatedstorage and it'll work.

Ad

Answer this question