generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Changing Shirt Script

Previous Thread :: Next Thread 
werts150 is not online. werts150
Joined: 11 Nov 2012
Total Posts: 1450
01 Mar 2013 01:31 PM
My script I made isn't working. It's supposed to change your shirt when you click a GUI button. When I click the button, if you don't have a shirt on it works, but if you already have a shirt on it doesn't do anything. Here is my script:

local shirt = script.Parent.Parent.Parent.Parent.Parent.Character:GetChildren()
for i=1,#shirt do
if (shirt[i].className == "Shirt" or shirt[i].className == "Clothing") then
shirt[i].ShirtTemplate = "http://www.roblox.com/asset/?id=106787505"
end
if not shirt.className ~= "Shirt" then
orange = Instance.new("Shirt", script.Parent.Parent.Parent.Parent.Parent.Character)
orange.ShirtTemplate = "http://www.roblox.com/asset/?id=106787505"
end
end
end

So basically, it works PERFECTLY in play solo. But when I actually test the game in a server, it doesn't work. Why is that happening?
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
01 Mar 2013 01:51 PM
if not shirt.
should be
if not shirt[i].
AND that line is the same as saying
if shirt[i].ClassName == "Shirt" then
because your using a double negative, Another source of error may be that your script will also try and change the ShirtTemplate property of pants, which they do not have and as such will cause an error, but you must also consider whether or not it is in a local script because sometimes that can cause errors when it comes to GUIs and tools.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
01 Mar 2013 01:52 PM
Also add a wait() at the top of the script, sometimes it loads before the Player and that can cause an error.
Report Abuse
werts150 is not online. werts150
Joined: 11 Nov 2012
Total Posts: 1450
01 Mar 2013 02:36 PM
Okay, thanks. I fixed the double negative and the wait. I also added the [i]. But its the top part that isn't working, not the bottom part. When I don't have a shirt on, it adds it perfectly. But when I do have a shirt on, which is the top part, it doesn't change anything. There's no errors either.
Report Abuse
werts150 is not online. werts150
Joined: 11 Nov 2012
Total Posts: 1450
01 Mar 2013 04:49 PM
Anyone? Please?
Report Abuse
werts150 is not online. werts150
Joined: 11 Nov 2012
Total Posts: 1450
01 Mar 2013 07:17 PM
Bummmmmmp....
Report Abuse
werts150 is not online. werts150
Joined: 11 Nov 2012
Total Posts: 1450
01 Mar 2013 10:41 PM
Bump again... ;(
Report Abuse
Joseph96gr is not online. Joseph96gr
Joined: 28 Aug 2012
Total Posts: 383
01 Mar 2013 10:54 PM
if you have an issue you dont seem to solve, go around:

Workspace.PLAYERNAME.Shirt:Destroy( )

modify that to remove your shirt at the click of the button, then replace it with the new shirt
Report Abuse
werts150 is not online. werts150
Joined: 11 Nov 2012
Total Posts: 1450
02 Mar 2013 12:06 AM
Wow, thanks! It worked!
Report Abuse
Joseph96gr is not online. Joseph96gr
Joined: 28 Aug 2012
Total Posts: 383
02 Mar 2013 02:26 PM
i didn't think it would work, but i guess it did. you said that if you didn't have as shirt on, it would put on the other shirt. already having one on, it would appear nothing happened. try putting a decal on a decal, the older one sometimes stays on top... glad it worked though
Report Abuse
werts150 is not online. werts150
Joined: 11 Nov 2012
Total Posts: 1450
02 Mar 2013 02:46 PM
Well I didn't use your code, but I never thought of removing it and adding it. I was trying to change it, which is what wasn't working. Thanks again ;)
Report Abuse
westland2 is not online. westland2
Joined: 09 Nov 2012
Total Posts: 1
15 Dec 2013 11:49 PM
Could you copy and paste your script? I really have trouble with creating scripts
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image