brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 23 Dec 2012 01:59 PM |
Why does this crash my game?
Player = game.Players.LocalPlayer mouse = Player:GetMouse()
local Object
Wait = false
mouse.Button1Down:connect(function() wait() Object = mouse and mouse.Target.Parent and mouse.Target.Parent.Parent if Object.Name == "Jail_Door" and not Wait then Wait = true if Object["Open/Close"].Value then Object["Open/Close"].Value = false elseif not Object["Open/Close"].Value then Object["Open/Close"].Value = true end wait(2) Wait = false end end) |
|
|
| Report Abuse |
|
|
| |
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 23 Dec 2012 02:03 PM |
| Object = mouse and mouse.Target.Parent and mouse.Target.Parent.Parent |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2012 02:44 PM |
| Put object at the beginning of the script with everything else |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
| |
|
Monkey727
|
  |
| Joined: 12 Jan 2009 |
| Total Posts: 969 |
|
|
| 23 Dec 2012 02:54 PM |
| I don't think a variable can have 3 values. |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 23 Dec 2012 03:00 PM |
| Can someone please give me a logical explanation? |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 23 Dec 2012 03:02 PM |
More info on how it crashs:
Only crashs if you spam click... |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 23 Dec 2012 03:02 PM |
More info on how it crashs:
Only crashs if you spam click... |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 23 Dec 2012 03:04 PM |
| lolcal Object needs to be removed. It would crash because it would have to keep repeating finding out what the player with because of your second object variable. Try adding a wait before it. |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 23 Dec 2012 03:10 PM |
| I'm not sure if I know what you mean, Could you please rearrange my script to be as you said? |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
| |
|
Jlobblet
|
  |
| Joined: 05 Sep 2010 |
| Total Posts: 587 |
|
|
| 23 Dec 2012 03:36 PM |
Door script could be:
system = script.Parent door = { open = false; door = system.Door; button = system.button;--contains ClickDetector doorToggle = function(self) open = not open door.CanCollide = not door.CanCollide if open then door.Transparency = 0.5 else door.Transparency = 0 end end}
door.Button.ClickDetector.MouseClick:connect( function () door:doorToggle() end)
Might work, might not. This is just the basis of some code. DIY.(Debug it yourself)
~if not ok then return end |
|
|
| Report Abuse |
|
|
MrTechn0
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 1252 |
|
| |
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 23 Dec 2012 03:39 PM |
| To me it appears you're setting Object to a Boolean. |
|
|
| Report Abuse |
|
|
Jlobblet
|
  |
| Joined: 05 Sep 2010 |
| Total Posts: 587 |
|
|
| 23 Dec 2012 03:40 PM |
Doesn't need it; instantaneous change(well, milliseconds.)
~if not ok then return end |
|
|
| Report Abuse |
|
|
brayden99
|
  |
| Joined: 30 Sep 2007 |
| Total Posts: 1243 |
|
|
| 23 Dec 2012 03:47 PM |
| @Jlobblet, Not what i'm trying to do lol |
|
|
| Report Abuse |
|
|
Jlobblet
|
  |
| Joined: 05 Sep 2010 |
| Total Posts: 587 |
|
|
| 23 Dec 2012 03:53 PM |
"Object = mouse and mouse.Target.Parent and mouse.Target.Parent.Parent"
Use a table:
Object = {["mouse"] = mouse} etcetera. Call it via Object["mouse"]
~if not ok then return end |
|
|
| Report Abuse |
|
|
1Topcop
|
  |
| Joined: 09 Jun 2009 |
| Total Posts: 6635 |
|
|
| 23 Dec 2012 04:01 PM |
wait() Player = game.Players.LocalPlayer mouse = Player:GetMouse() local Object Waiting = false -- Maybe because it's getting confused with wait()?
mouse.Button1Down:connect(function() wait() Object = mouse and mouse.Target.Parent and mouse.Target.Parent.Parent -- I thought about it.. and then realized this wouldn't make Object a Boolean. if(not Object or not Waiting)then return end --- If there is no Object, or we're waiting, get out of this function. if(Object.Name=="Jail_Door")then Waiting = true Object["Open/Close"].Value = not Object["Open/Close"].Value wait(2) Waiting = false end end) |
|
|
| Report Abuse |
|
|