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

[Solved] StarterGear not going into backpack when I spawn?

Asked by 8 years ago
Edited 8 years ago

So I'm making a weapon select GUI with one master script for each category of weapons that gives you the weapon you want, if you have enough points for it, and it does this for each button, as long as the options inside them exist. So far, it works perfectly, except for one thing. Clicking the button clears your player's StarterGear and puts the new weapon inside it, so you get the weapon next time you respawn. It works fine with singleplayer testing, but in a server, it doesn't give me my startergear tools when I spawn in, even though it does put the weapon in there, handle and everything. Is this a problem with my script, or a problem with roblox? Here's the part of my script that puts the weapon in your player's startergear, where weapon is a variable for the button's "Weapon" ObjectValue, which links to a tool in ReplicatedStorage

local startergears = player.StarterGear:GetChildren()
for i = 1, #startergears do
    startergears[i]:Destroy()
end
local newweapon = weapon.Value:Clone()
newweapon.Parent = player.StarterGear

I really hope this isn't a problem with Roblox, because other than startergear, I have no idea how to make the weapon you've selected save after you die, and I don't want my players to have to select the weapon again everytime they respawn by putting the weapon in their backpack. If you need need more of my script, please let me know.

0
This is a server side script, correct? Also, you are  absolutely sure the tool in ReplicatedStorage exists, right? ObjectValues *link* to an object, they do not store an object. Monsieur_Robert 338 — 8y
0
Yes, it exists. I put the tools in there in studio, and the menu puts the items in your startergear as it should. The problem isn't with the menu giving you weapons, but with your startergear giving you the weapons when you spawn. It's a localscript inside the GUI and filtering isn't enabled. WesleyTheSkunk 12 — 8y
0
Why not use StarterPack? script_help 74 — 8y
0
Also, just for a nitpick, you can use the :ClearAllChildren() method instead of your for loop. Just a way to reduce number of lines of code you have. script_help 74 — 8y
View all comments (4 more)
0
Wait a minute, why was I using that loop? I know how ClearAllChildren works, I don't know why I didn't just use that lol. Also, if it put it into starterpack, that would change the weapon every player spawns with. I only want the player who selected the weapon to spawn with it. WesleyTheSkunk 12 — 8y
0
Now that I think about it, I could just make a simple loop to clone your startergear to your backpack each time you spawn as a temporary solution to this. I'll try that now. WesleyTheSkunk 12 — 8y
0
My cloning loop worked! It's probably not the best solution, but it'll do for now. WesleyTheSkunk 12 — 8y
0
idk what happened but I made the game filteringenabled and now it doesn't even need a loop :D WesleyTheSkunk 12 — 7y

Answer this question