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: GAH. Why won't this simple snippet of code work?

Previous Thread :: Next Thread 
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:20 PM
It prints "bear mode", but then roblox crashes. No output, just "We're sorry! Roblox has had an unexpected error and needs to quit."

print("bear mode")
newchar = game.Lighting.Bear:Clone()
newchar:MakeJoints()
newchar.Parent = workspace
newchar:MakeJoints()
pl.Character = newchar
wait(30)
newchar:Remove()
fbody = Instance.new("Model",workspace)
ftorso = Instance.new("Part",fbody)
ftorso.Transparency = 1
ftorso.CanCollide = false
ftorso.Anchored = true
ftorso.Name = "Torso"
ftorso.Position = Vector3.new(10000,10000,10000)
fhum = Instance.new("Humanoid",fbody)
fhum.Torso = ftorso
pl.Character = fbody
Report Abuse
flappydavid is not online. flappydavid
Joined: 03 May 2009
Total Posts: 5893
08 Jul 2011 08:23 PM
That's weird...
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:24 PM
Also, I'll tried this in Build mode to see the output. I'll try Play really quick.
Report Abuse
stoopidfaic is not online. stoopidfaic
Joined: 02 Jul 2011
Total Posts: 284
08 Jul 2011 08:24 PM
Maybe there should only be one MakeJoints?
Report Abuse
deathman12e3 is not online. deathman12e3
Joined: 10 Nov 2009
Total Posts: 7284
08 Jul 2011 08:26 PM
Place markers.
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:27 PM
@stoopid

That wouldn't make roblox crash.

@death kay
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 Jul 2011 08:29 PM
LOLOLOLOLOLOLOL

:P

You're using a CharacterAdded event to change the character. Nice work! XD
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:31 PM
@AFF

OH GOD IS THAT WRONG?

Anyway, it stops right before it waits to change the player back.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 Jul 2011 08:33 PM
Every time you change the Character to something else, the CharacterAdded event fires. This means you create an infinite amount of threads in a time of 0 seconds.

That is bad for RBX API. ^_<
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:34 PM
Okay. How would I go about preventing that? Should I change the way I make the character return (I can't think of any other way D:)
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 Jul 2011 08:38 PM
A simple bool value will fix it.


local bearifying = false
--Beginning of PlayerAdded function






print("bear mode")
if not bearifying then
bearifying = true
newchar = game.Lighting.Bear:Clone()
newchar:MakeJoints()
newchar.Parent = workspace
newchar:MakeJoints()
pl.Character = newchar
wait(30)
newchar:Remove()
fbody = Instance.new("Model",workspace)
ftorso = Instance.new("Part",fbody)
ftorso.Transparency = 1
ftorso.CanCollide = false
ftorso.Anchored = true
ftorso.Name = "Torso"
ftorso.Position = Vector3.new(10000,10000,10000)
fhum = Instance.new("Humanoid",fbody)
fhum.Torso = ftorso
pl.Character = fbody
bearifying = false
end
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:39 PM
Oh, wow. Thanks. You always help me out when I'm in a pickle <3
Report Abuse
Biostream is not online. Biostream
Joined: 28 Mar 2011
Total Posts: 913
08 Jul 2011 08:39 PM
Just do game.Players.ChildAdded, not CharacterAdded
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:42 PM
Gah. It still goes crashy. Also, this is a tool, biostream. ._.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 Jul 2011 08:43 PM
o.o

Post the entire script. Include your CharacterAdded script as well.
Report Abuse
Biostream is not online. Biostream
Joined: 28 Mar 2011
Total Posts: 913
08 Jul 2011 08:44 PM
Oh. I didnt know.
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:44 PM
I don't have one, it's just a tool.

bearifying = false
dpsring = false
mode = script.Parent.Mode
script.Parent.Equipped:connect(function(m)
m.KeyDown:connect(function(k)
if k:lower() == "r" then
if mode.Value == 1 or mode.Value == 2 then
mode.Value = mode.Value + 1
print("mode" .. mode.Value)
elseif mode.Value == 3 then
mode.Value = 1
print("mode" .. mode.Value)
end
elseif k:lower() == "e" then
if mode.Value == 3 or mode.Value == 2 then
mode.Value = mode.Value - 1
print("mode" .. mode.Value)
elseif mode.Value == 1 then
mode.Value = 3
print("mode" .. mode.Value)
end
end
end)
m.Button1Down:connect(function()
pl = game.Players.LocalPlayer
ch = pl.Character
if mode.Value == 1 and m.Hit and (ch.Torso.Position - m.Hit.p).magnitude <= 20 and not dpsring then
dpsring = true
cfr = m.Hit.p + Vector3.new(0,.3,0)
print("omgmode1")
p = Instance.new("Part", ch)
d = Instance.new("Decal", p)
d.Texture = "http://www.roblox.com/asset/?id=55663565"
d.Face = "Top"
d1 = d:Clone()
d1.Parent = p
d1.Texture = d.Texture
d1.Face = "Bottom"
p.formFactor = "Custom"
p.Size = Vector3.new(5,1,5)
p.Transparency = 1
p.CanCollide = false
p.Anchored = true
p.CFrame = CFrame.new(cfr)
wait(3)
for i=1, 3, .1 do
p.Size = p.Size + Vector3.new(1,0,1)
p.CFrame = CFrame.new(cfr + Vector3.new(0,i*2,0))
wait(.1)
p.Size = p.Size + Vector3.new(1,0,1)
p.CFrame = CFrame.new(cfr + Vector3.new(0,i*2,0))
wait(.1)
p.Size = p.Size + Vector3.new(1,0,1)
p.CFrame = CFrame.new(cfr + Vector3.new(0,i*2,0))
wait(.1)
p.Size = p.Size + Vector3.new(1,0,1)
p.CFrame = CFrame.new(cfr + Vector3.new(0,i*2,0))
wait(.1)
end
p:Remove()
dpsring = false
elseif mode.Value == 2 then
print("bear mode")
if not bearifying then
bearifying = true
newchar = game.Lighting.Bear:Clone()
print("clone")
newchar:MakeJoints()
print("madejoints1")
newchar.Parent = workspace
print("parented")
newchar:MakeJoints()
print("madejoints2")
pl.Character = newchar
print("madechar")
wait(30)
print("waited")
newchar:Remove()
fbody = Instance.new("Model",workspace)
ftorso = Instance.new("Part",fbody)
ftorso.Transparency = 1
ftorso.CanCollide = false
ftorso.Anchored = true
ftorso.Name = "Torso"
ftorso.Position = Vector3.new(10000,10000,10000)
fhum = Instance.new("Humanoid",fbody)
fhum.Torso = ftorso
pl.Character = fbody
bearifying = false
end
end
end)
end)
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 Jul 2011 08:46 PM
What does the Output print? I can't see the error.
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 08:48 PM
It doesn't print any error, but it crashes right after it prints "madechar"
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
08 Jul 2011 09:35 PM
Bump.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
08 Jul 2011 09:57 PM
I don't have an answer, so take a free bump.
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
09 Jul 2011 11:50 AM
Bump of holycrapAFFdoesn'tknowtheanswer
Report Abuse
Jaccob is not online. Jaccob
Joined: 19 Oct 2008
Total Posts: 986
09 Jul 2011 11:52 AM
D:
Report Abuse
goldfriend10 is not online. goldfriend10
Joined: 13 Mar 2009
Total Posts: 524
09 Jul 2011 12:01 PM
Wow this should be a major error in Roblox...
Report Abuse
zeke505 is not online. zeke505
Joined: 26 May 2008
Total Posts: 15765
09 Jul 2011 01:08 PM
Bump of I need help D:
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