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: Why does this keep crashing my game?

Previous Thread :: Next Thread 
brayden99 is not online. 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
FlamedSkull is not online. FlamedSkull
Joined: 23 May 2009
Total Posts: 1379
23 Dec 2012 02:01 PM
You never defined Object?
Report Abuse
brayden99 is not online. 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
bluetechdude2 is not online. bluetechdude2
Joined: 23 May 2011
Total Posts: 495
23 Dec 2012 02:44 PM
Put object at the beginning of the script with everything else
Report Abuse
brayden99 is not online. brayden99
Joined: 30 Sep 2007
Total Posts: 1243
23 Dec 2012 02:49 PM
What do you mean?
Report Abuse
Monkey727 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. brayden99
Joined: 30 Sep 2007
Total Posts: 1243
23 Dec 2012 03:29 PM
Flump.
Report Abuse
Jlobblet is not online. 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 is not online. MrTechn0
Joined: 23 Nov 2012
Total Posts: 1252
23 Dec 2012 03:37 PM
put a debounce in
Report Abuse
1Topcop is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
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