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

Can anyone PLEASE Check my Script? Its not accesing the Gun in Roblox Player

Asked by 7 years ago
player = game.Players.LocalPlayer
money = player.leaderstats.Captures
price = 0
tool = game.ServerStorage:findFirstChild("Burst")


function buy()
if money.Value >= price then
money.Value = money.Value - price
local a = tool:clone()
a.Parent = player.Backpack
local b = tool:clone()
b.Parent = player.StarterGear

end
end
script.Parent.MouseButton1Down:connect(buy)

This is a local script! I dont know whats wrong with it! Its a Local Script! I added the guns in Server Storage! But its still not working! The gun is named Burst

0
Local scrips do not have access to ServerStorage User#5423 17 — 7y
0
Try rep storage User#5423 17 — 7y
0
ok PartyScripters 20 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You need to write it so that it waits for 'player.leaderstats.Captures'

you can write something like...

player = game.Players.LocalPlayer

if not player.leaderstats then wait() end

money = player.leaderstats.Captures
price = 0
tool = game.ServerStorage:findFirstChild("Burst")

then write the rest of your script... just add that if not player.leaderstats then wait() end because the player is taking a while to load so the script is gonna be like "wut r u doin" but yeah just make it wait for the player's children to load :)

0
Thanks! That helped alot, but it still is not loading in Player Mode! The Tool is in ReplicatedStorage, becuase I heard that local scripts can Acces ServerStorage, but I also changed the Script to adapt to that! So should that be a script? Or should it stay a local script? PartyScripters 20 — 7y
0
Hi :) Is there any error message in the console? If there is, please paste it here. :) shasta342 37 — 7y
Ad

Answer this question