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

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

Asked by 5 years ago
Edited 5 years ago

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)
0
What's the chr for? The script only has the chr in one place. Bilinearly 58 — 5y
0
Did you just combine many scripts to get that; because on the line 4, you have done a mistake :/ AIphanium 124 — 5y
0
If you change line 4 to PlayerAdded:Connect(function(plr) then it works fine Vulkarin 581 — 5y

1 answer

Log in to vote
0
Answered by
AIphanium 124
5 years ago
Edited 5 years ago

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.

0
On a side note you should probably make sure backpack exists Vulkarin 581 — 5y
0
@Vulkarin, its a function, once the function detects if the player's name is Quibblish, it means that the player exist already! AIphanium 124 — 5y
0
Also, "CHECKED AND FIXED" the script in Studio. AIphanium 124 — 5y
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 Vulkarin 581 — 5y
View all comments (15 more)
0
Your script will run when he joins, his backpack will only load later along with his character Vulkarin 581 — 5y
0
Alright, just added a simple line which waits a little bit, because you know... that error only happens at STUDIO... AIphanium 124 — 5y
0
You don't seem to understand the loading order very well Vulkarin 581 — 5y
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 Vulkarin 581 — 5y
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. AIphanium 124 — 5y
0
Alright, i give up, created the second script. AIphanium 124 — 5y
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 Vulkarin 581 — 5y
0
Okay, okay, you win. AIphanium 124 — 5y
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. Quibblish 9 — 5y
0
Also, the second script adds the boombox to my backpack if it detects that my avatar doesn't exist. Quibblish 9 — 5y
0
And also, Quibblish, if you carefully read... you detect that i have written something like this "~=", not "==", which does the opposite effect! AIphanium 124 — 5y
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) Vulkarin 581 — 5y
0
Whatever. AIphanium 124 — 5y
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. Quibblish 9 — 5y
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. AIphanium 124 — 5y
Ad

Answer this question