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

Why does this script that should put a gear into my personal backpack not work?

I've tried this script and many more, attempting to make a boombox that only goes into MY backpack as a player when i join my own game. I honestly don't see how this one wouldn't work. It doesn't even work in studio, so obviously it's not a filteringenabled problem. And all the paths are correct. Help?

local players = {"Quibblish"}
local gear = game.ServerStorage.BoomBox

game.Players.PlayerAdded.connect(function(plr)
 plr.CharacterAdded:Connect(function(chr)
  for i = 1, #players do
   if players[i] == plr.Name then
    gear:Clone().Parent = plr:WaitForChild("Backpack")
   end
  end
 end)
end)

3 comments

0

What's the chr for? The script only has the chr in one place.

0

Did you just combine many scripts to get that; because on the line 4, you have done a mistake :/

0

If you change line 4 to PlayerAdded:Connect(function(plr) then it works fine

1 answer

Hello, Quibblish!

I have been trying to make a new script for you... so... here it is!

-- Removed, because the asker wanted someone with a higher reputation.

Created a second script!

-- Removed, because the asker wanted someone with a higher reputation.

---- Hope i helped.

------- AIphanium.

19 comments

0

On a side note you should probably make sure backpack exists

0

@Vulkarin, its a function, once the function detects if the player's name is Quibblish, it means that the player exist already!

0

Also, "CHECKED AND FIXED" the script in Studio.

0

You assume that Quibblish has a backpack, which may not be true and cause it to error (The server will notice Quibblish joined the game and run the function far before he has a backpack)...and that means Quibblish will never get his gear because the PlayerAdded event doesn't run on respawn, only on his join

0

Your script will run when he joins, his backpack will only load later along with his character

0

Alright, just added a simple line which waits a little bit, because you know... that error only happens at STUDIO...

0

You don't seem to understand the loading order very well

0

The server is always going to notice you entering the game before your backpack loads whether studio or not, Quibblish script is what should be done in the script

0

I DO understand, but there is a difference between STUDIO and normal GAMEPLAY, in the STUDIO, scripts load before the character, but in the normal gameplay, scripts load once a player joins a server.

0

Alright, i give up, created the second script.

0

No, the server controls the scripts and they will load first irrelevant of whether or not a player joined, in the case of this script the server will acknowledge the PlayerAdded event far before your backpack exists

0

Okay, okay, you win.

0

I'm not exactly a professional in the order things load in, but i'm pretty sure vulkarin is right. However, like Alphanium mentioned, he DID put a little delay and, as long as I don't take over 10 seconds to load, the delay SHOULD do its job, right? It adds the boombox to my backpack 10 seconds after i click the play button, again, granted that I load in before 10 seconds is up.

0

Also, the second script adds the boombox to my backpack if it detects that my avatar doesn't exist.

0

And also, Quibblish, if you carefully read... you detect that i have written something like this "~=", not "==", which does the opposite effect!

0

The only error in your own script is the 4th line, should you fix it it will be much more fail proof than a 10 second wait or a checking of the workspace (which still doesn't address the error being that your player is detected and the function is ran before the backpack exists)

0

Whatever.

0

my eyes are awful. anyways, Vulkarin, you should actually answer the question. the answer button and box are at the very bottom of the page. That way, I can close this thread.

0

Quibblish, there is no difference between me, and Vulkarin, your question is better to be left unanswered, if you really care about someone with a higher reputation, then go and find one.

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