Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

3 comments

0

Local scrips do not have access to ServerStorage

0

Try rep storage

0

ok

1 answer

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 :)

2 comments

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?

0

Hi :) Is there any error message in the console? If there is, please paste it here. :)

This discussion is preserved as it was. New answers, comments, and votes are closed.