|
| 01 Mar 2014 09:27 AM |
How would I go about checking if the player is wearing a certain shirt when they join? The problem I'm currently having is that the script fails to check if the player's shirt loaded, which I thought was the same as waiting for their character.
I have a player.CharacterAdded:wait() ONLY if their character does not exist, and an if and then check for their shirt and t-shirt, and a for loop looping through their character just in case along with the if and then, and neither is detecting the shirt for some reason.
How can I wait until their character's shirt has loaded. I can't do repeat wait() until player.Character:findFirstChild("Shirt") because player's may not be wearing a shirt, so it would repeat forever and not continue the code.
Please help! Thanks! |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2014 10:26 AM |
| TL;DR: How can I wait until a player's shirt has loaded when they join the game? I can't do repeat wait() until player.Character:findFirstChild("Shirt") because player's may not be wearing a shirt, so it would repeat forever and not continue the code. |
|
|
| Report Abuse |
|
|
| |
|
|
| 01 Mar 2014 03:26 PM |
| Bump please help someone!!! |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Mar 2014 01:17 PM |
| Last bump before repost COME ON GUYS!!! |
|
|
| Report Abuse |
|
|
|
| 02 Mar 2014 01:27 PM |
Is it a T-shirt or a shirt it's trying to detect? There is no real object for t-shirts, it just places a decal on the player's torso.
|
|
|
| Report Abuse |
|
|
|
| 03 Mar 2014 04:17 PM |
There actually is, it's calle ShirtGraphic.
I actually have both a Shirt and T-Shirt, so both :P.
I want to award different points based on if they are wearing the shirt or t-shirt. |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2014 06:54 PM |
I know about ShirtGraphics, but when a player actually wears a t-shirt into the game it just sticks a decal on their torso. I don't know why, but I was trying to figure out why my script wasn't detecting t-shirts and I discovered that's why.
Are you using IsA to look for the shirt/t-shirt?
|
|
|
| Report Abuse |
|
|
|
| 04 Mar 2014 10:43 PM |
Yes I am doing exactly that lol.
So in Studio mode when you test your character, it shows a ShirtGraphic, but online it is a Decal on Torso? Weird.
Im having trouble with Shirts too :P. |
|
|
| Report Abuse |
|
|
|
| 05 Mar 2014 07:40 PM |
Hm, maybe they updated it so it does put a ShirtGraphic on you. You can check by opening a test server and player - F7 to start a server then Alt + F7 to start a player.
Are you detecting when the player joins or spawns?
|
|
|
| Report Abuse |
|
|
|
| 05 Mar 2014 07:43 PM |
Whoops, just remembered what you said in your first post. Why don't you try a simple script, then add on to it? I'm not quite sure what your problem is exactly.
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) print(player.Name.." spawned") for i,v in pairs(char:GetChildren()) do if v:IsA("Shirt") then print(player.Name.." has a shirt!") elseif v:IsA("ShirtGraphic") then print(player.NAme.." has a t-shirt!") end end end) end)
|
|
|
| Report Abuse |
|
|
|
| 05 Mar 2014 07:47 PM |
| elseif v:IsA("ShirtGraphic") and v.Texture = "" then--just add that bit |
|
|
| Report Abuse |
|
|
|
| 06 Mar 2014 03:49 PM |
| I have practically that exact code, but the problem seems to be that it checks if the shirt is the right texture before the shirt loads, but after the player's character loads. Not quite sure about this, but I added elses to print stuff if it has the wrong texture and it does that in server mode in Studio even if Im wearing the right shirt/t-shirt. It's very weird. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 07 Mar 2014 05:25 PM |
This should be the answer to your question
http://wiki.roblox.com/index.php/API:Instance/WaitForChild |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2014 05:29 PM |
| I know about that. I could wait for the shirt. However the issue with that is that it's possible that they aren't wearing any shirt, which would make the code wait forever. Is there a way around this? |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2014 05:34 PM |
coroutine.resume(coroutine.create(function() player:WaitForChild('Shirt' or 'ShirtGraphic') --Code that gives benefits to player if wearing the shirt needed. end))
That will allow it to wait for the shirt but run the rest of the script while its waiting. |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2014 05:53 PM |
| OMG THANK YOU I know coroutines but didn't realize they would be useful I willl try it and see if it works!!! |
|
|
| Report Abuse |
|
|
|
| 14 Mar 2014 12:56 PM |
| Still didn't work :(. Didn't even print anything (so the coroutine seems to not be running). |
|
|
| Report Abuse |
|
|
|
| 15 Mar 2014 04:20 PM |
I fixed it and now it works fine except for 1 very minor problem:
If I do the following:
:WaitForChild("Shirt" or "Shirt Graphic")
It waits for the shirt, and not the shirt graphic every time. If I flip them it does the opposite. I want it to wait until there is a shirt or a shirt graphic, but that's not how Lua's or operator works :(. Help! |
|
|
| Report Abuse |
|
|
|
| 16 Mar 2014 02:44 PM |
Have two different :WaitForChild() statements: :WaitForChild("Shirt") :WaitForChild("ShirtGraphic").
|
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 01:53 PM |
| Then if the player is wearing the ShirtGraphic it will wait forever since the :WaitForChild("Shirt") will never be true. |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2014 02:11 PM |
That's why I'd suggest using a for loop on the player (for i,v in pairs(player:GetChildren())), then "if v:IsA("ShirtGraphic") or v:IsA("Shirt") then do stuff".
|
|
|
| Report Abuse |
|
|