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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
| |
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
| |
|
werts150
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
| |
|
|
| 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
|
  |
| Joined: 11 Nov 2012 |
| Total Posts: 1450 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 15 Dec 2013 11:49 PM |
| Could you copy and paste your script? I really have trouble with creating scripts |
|
|
| Report Abuse |
|
|