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

Where can I put localscripts and how would I convert them into normal scripts?

Asked by 6 years ago

Hello. You may or may not know my previous question about updating CoderQwerty's outdated "Random Weapon Script". Apparently it's not so outdated after all. Regardless, I found out what I was supposed to do, and now I need help again.

Everything is set up and in place, except for one problem.

The script is a localscript, and I do not know where to put it in my game, the differences between localscripts and normal scripts, and how I can convert localscript to normal script correctly in an efficient way.


-- RANDOM WEAPON -- Qwerty1806 -- 2014:07:25 -- Simply place all of the weapons you want to randomly give out inside a backpack called 'Weapons' in ReplicatedStorage. Weapons = game.ReplicatedStorage.Weapons:GetChildren() local Weapon = Weapons[math.random(1,#Weapons)]:Clone() Weapon.Parent = game.Players.LocalPlayer.Backpack

What I have done so far is create a folder, name it "Weapons", place it in ReplicatedStorage (where the script says to place it), and place the localscript itself into StarterPlayerScripts, and the weapon doesn't work whatsoever.

Yes, filteringenabled is disabled.

Testing in-game on studio with output viewing on, I catch this:

17:45:28.961 - Backpack is not a valid member of Player

17:45:28.962 - Stack Begin

17:45:28.963 - Script 'Players.TitaneumCat.PlayerScripts.RandomWeapon', Line 10

17:45:28.964 - Stack End

Problems? I don't know. There is more in the output, but mainly based on other scripts and these lines have the most relation to the Random Weapon Script.

If this problem has to do with the location of the localscript being in StarterPlayerScripts, then please give me an example of a correct location, if there are any better areas.

If it has to do with the script being a localscript itself, then can anyone suggest how I might be able to convert it to a regular script, and it being a regular script with benefits?

If anyone can give any advice, an answer to any script problems, script fixes, or just a suggestion, I will be forever grateful.

I'm sorry if this question is frequent or has already been answered numerous times.

1 answer

Log in to vote
0
Answered by 6 years ago

You should do this in a script and I recommend to place the weapons in ServerStorage.


Weapons = game.ServerStorage.Weapons:GetChildren() game.Players.PlayerAdded:Connect(function(player) local Weapon = Weapons[math.random(1,#Weapons)]:Clone() Weapon.Parent = player:WaitForChild('Backpack') end)
0
I wrote your script, placed all weapons in ServerStorage, and followed all other steps, but it doesn't work at all. I don't even know why, Sorry, and thanks for your answer. TitaneumCat 24 — 6y
0
Works for me. Are you using a custom backpack GUI or something? KamikazeShard 23 — 6y
Ad

Answer this question