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
8 years ago

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

01Price = 5
02Player = game.Players.LocalPlayer
03local SpeedCoil = game.ServerStorage.Weapons.SpeedCoil
04local Taken = SpeedCoil.Taken
05 
06script.Parent.MouseButton1Click:connect(function()
07    if Player:FindFirstChild("leaderstats") and Player.leaderstats["Gold bars"].Value >= Price then
08        if Taken.Value == false then
09            Player.leaderstats["Gold bars"].Value = Player.leaderstats["Gold bars"].Value - Price
10            SpeedCoil:Clone().Parent = Player.Backpack
11            SpeedCoil:Clone().Parent = Player.StarterGear
12            Taken.Value = true
13        end
14    end
15end)

1 answer

Log in to vote
1
Answered by 8 years ago

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

Ad

Answer this question