|
| 12 May 2012 09:55 PM |
This is a script that I wrote myself to make a gun change between semi and full automatic when you press T. "Shooter" is the full auto script, "Shooter2" is for semi auto.
function switch() if KeyDownFunctions == "t" and script.parent.LocalScript "Shooter".Disabled = false then script.parent.LocalScript "Shooter".Disabled = true script.parent.LocalScript "Shooter2".Disabled = false else if KeyDownFunctions == "t" and script.parent.LocalScript "Shooter".Disabled = true then script.parent.LocalScript "Shooter".Disabled = false script.parent.LocalScript "Shooter2".Disabled = true end
Please help me with this, I need it as soon as possible. |
|
|
| Report Abuse |
|
|
HuntHello
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 577 |
|
| |
|
abaw7
|
  |
| Joined: 23 Oct 2009 |
| Total Posts: 745 |
|
|
| 12 May 2012 09:59 PM |
Make the LocalScript Shooter and Shooter2 named Shooter and Shooter2 then:
function switch() if KeyDownFunctions == "t" and script.parent["Shooter"].Disabled = false then script.parent.LocalScript "Shooter".Disabled = true script.parent.LocalScript "Shooter2".Disabled = false else if KeyDownFunctions == "t" and script.parent["Shooter"].Disabled = true then script.parent["Shooter"].Disabled = false script.parent["Shooter2"].Disabled = true end
|
|
|
| Report Abuse |
|
|
abaw7
|
  |
| Joined: 23 Oct 2009 |
| Total Posts: 745 |
|
|
| 12 May 2012 09:59 PM |
Also add in another end. function switch() if KeyDownFunctions == "t" and script.parent["Shooter"].Disabled = false then script.parent.LocalScript "Shooter".Disabled = true script.parent.LocalScript "Shooter2".Disabled = false else if KeyDownFunctions == "t" and script.parent["Shooter"].Disabled = true then script.parent["Shooter"].Disabled = false script.parent["Shooter2"].Disabled = true end end |
|
|
| Report Abuse |
|
|
Nyht
|
  |
| Joined: 18 Apr 2011 |
| Total Posts: 41 |
|
|
| 12 May 2012 10:02 PM |
Got no errors once I ran this:
function switch() if KeyDownFunctions == "t" and script.parent.LocalScript "Shooter".Disabled == false then script.parent.LocalScript "Shooter".Disabled = true script.parent.LocalScript "Shooter2".Disabled = false else if KeyDownFunctions == "t" and script.parent.LocalScript "Shooter".Disabled == true then script.parent.LocalScript "Shooter".Disabled = false script.parent.LocalScript "Shooter2".Disabled = true end end end
|
|
|
| Report Abuse |
|
|
Nyht
|
  |
| Joined: 18 Apr 2011 |
| Total Posts: 41 |
|
|
| 12 May 2012 10:04 PM |
I ran it three times before I got no more errors, and these were the errors:
workspace.Script:2: 'then' expected near '=' (forgot an '=' sign both on line 2 and 4) Workspace.Script:9: 'end' expected (to close 'if' at line 2) near '< eof >' (forgot an end) Workspace.Script:9: 'end' expected (to close 'function' at line 1) near '< eof >' (forgot an end) |
|
|
| Report Abuse |
|
|
abaw7
|
  |
| Joined: 23 Oct 2009 |
| Total Posts: 745 |
|
|
| 12 May 2012 10:05 PM |
That's odd. Also I forgot to completely edit it.
function switch() if KeyDownFunctions == "t" and script.parent["Shooter"].Disabled == false then script.parent["Shooter"].Disabled = true script.parent["Shooter2"].Disabled = false elseif KeyDownFunctions == "t" and script.parent["Shooter"].Disabled == true then script.parent["Shooter"].Disabled = false script.parent["Shooter2"].Disabled = true end end
There you go |
|
|
| Report Abuse |
|
|
Nyht
|
  |
| Joined: 18 Apr 2011 |
| Total Posts: 41 |
|
|
| 12 May 2012 10:10 PM |
| Oh, now I know why the third "end" was needed... elseif is one, not two, words. |
|
|
| Report Abuse |
|
|
|
| 12 May 2012 10:36 PM |
no, it still doesn't work. The main problem is that the two local scripts (shooter and shooter2) don't become enabled and disabled when I press t.
|
|
|
| Report Abuse |
|
|