|
| 10 Jun 2012 08:26 AM |
I'm trying to make crazyman's plane seat more advanced. I'm currently editing the Crash script so that a Hint is broadcasted upon a player crashing.
What I am trying to hopefully do is say "Oh no! (player) has crashed!"
This is what I have so far:
-- This script handles crash detection
while (not script.Parent.Cloned.Value) do wait() end wait(5)
if (not script.Parent.EDIT_THESE.CanCrash.Value) then script:remove() return end local maxImpact = script.Parent.EDIT_THESE.CanCrash.Force.Value
local crashT,explode = 0,false
local crashwarn Instance.new("Hint", game.Workspace) -- make a new hint when crashed crashwarn.Name = "crashwarn" -- name crashwarn.Text = "A plane has crashed! Oh no!" -- text
function goBoom() -- lol explode = true script.Parent.Dead.Stop.Value = true local x = Instance.new("Explosion") x.BlastPressure = 5e5 x.BlastRadius = script.Parent:GetModelSize().magnitude x.Position = script.Parent.MainParts.Main.Position script.Parent.MainParts.Main.Gyro:remove() x.Parent = game.Workspace end
function getParts(parent) for _,v in pairs(parent:GetChildren()) do if ((v:IsA("BasePart")) and (not v:IsDescendantOf(script.Parent.MainParts.LandingGear))) then v.Touched:connect(function(obj) if (not obj.Parent) then return end if ((not obj.CanCollide) or (not v.CanCollide)) then return end if (obj:IsDescendantOf(script.Parent)) then return end if (game.Players:GetPlayerFromCharacter(obj.Parent)) then return end if ( v.Velocity.x >= maxImpact or v.Velocity.x <= -(maxImpact) or v.Velocity.y >= maxImpact or v.Velocity.y <= -(maxImpact) or v.Velocity.z >= maxImpact or v.Velocity.z <= -(maxImpact) ) then if (not script.Parent.Dead.Value) then crashT = time() script.Parent.Dead.Value = true game:GetService("Debris"):AddItem(script.Parent,8) delay(6,function() pcall(function() script.Parent.MainParts.MainSeat.SeatWeld:remove() end) if (not explode) then goBoom() end end) end end if ((script.Parent.Dead.Value) and ((time()-crashT) > 0.5) and (not explode)) then goBoom() end end) end getParts(v) end end
getParts(script.Parent)
script.Parent.AutoCrash.Changed:connect(function() if (not script.Parent.AutoCrash.Value) then return end if ((not explode) and (not script.Parent.Dead.Value)) then crashT = time() script.Parent.Dead.Value = true game:GetService("Debris"):AddItem(script.Parent,8) goBoom() end end)
~𝓲𝓣𝓸𝓹𝓗𝓪𝓽𝓽𝓮𝓻 |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 10 Jun 2012 08:41 AM |
Pro tip. Replace:
if ( v.Velocity.x >= maxImpact or v.Velocity.x <= -(maxImpact) or v.Velocity.y >= maxImpact or v.Velocity.y <= -(maxImpact) or v.Velocity.z >= maxImpact or v.Velocity.z <= -(maxImpact) )
With
if v.Velocity.magnitude >= maxImpact |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 08:48 AM |
I fixed the hint instancing, there's a simple problem, the hint won't go away.
-- This script handles crash detection
while (not script.Parent.Cloned.Value) do wait() end wait(5)
if (not script.Parent.EDIT_THESE.CanCrash.Value) then script:remove() return end local maxImpact = script.Parent.EDIT_THESE.CanCrash.Force.Value
local crashT,explode = 0,false
function goBoom() -- lol explode = true script.Parent.Dead.Stop.Value = true local x = Instance.new("Explosion") x.BlastPressure = 5e5 x.BlastRadius = script.Parent:GetModelSize().magnitude x.Position = script.Parent.MainParts.Main.Position script.Parent.MainParts.Main.Gyro:remove() x.Parent = game.Workspace local Message = Instance.new("Hint", game.Workspace) Message.Name = "Hint" Message.Text = "A plane has crashed! Oh no!" wait(15) Message:remove() -- not working end
function getParts(parent) for _,v in pairs(parent:GetChildren()) do if ((v:IsA("BasePart")) and (not v:IsDescendantOf(script.Parent.MainParts.LandingGear))) then v.Touched:connect(function(obj) if (not obj.Parent) then return end if ((not obj.CanCollide) or (not v.CanCollide)) then return end if (obj:IsDescendantOf(script.Parent)) then return end if (game.Players:GetPlayerFromCharacter(obj.Parent)) then return end if v.Velocity.magnitude ?>= maxImpact then if (not script.Parent.Dead.Value) then crashT = time() script.Parent.Dead.Value = true game:GetService("Debris"):AddItem(script.Parent,8) delay(6,function() pcall(function() script.Parent.MainParts.MainSeat.SeatWeld:remove() end) if (not explode) then goBoom() end end) end end if ((script.Parent.Dead.Value) and ((time()-crashT) > 0.5) and (not explode)) then goBoom() end end) end getParts(v) end end
getParts(script.Parent)
script.Parent.AutoCrash.Changed:connect(function() if (not script.Parent.AutoCrash.Value) then return end if ((not explode) and (not script.Parent.Dead.Value)) then crashT = time() script.Parent.Dead.Value = true game:GetService("Debris"):AddItem(script.Parent,8) goBoom() end end)
~𝓲𝓣𝓸𝓹𝓗𝓪𝓽𝓽𝓮𝓻 |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
| |
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 10 Jun 2012 08:56 AM |
Also, that code is trying to be Lisp. It has way too many `(`s and `)`s. Here it is without them:
while not script.Parent.Cloned.Value do wait() end wait(5) if not script.Parent.EDIT_THESE.CanCrash.Value then script:remove() return end local maxImpact = script.Parent.EDIT_THESE.CanCrash.Force.Value local crashT, explode = 0, false function goBoom() -- lol explode = true script.Parent.Dead.Stop.Value = true local x = Instance.new("Explosion") x.BlastPressure = 5e5 x.BlastRadius = script.Parent:GetModelSize().magnitude x.Position = script.Parent.MainParts.Main.Position script.Parent.MainParts.Main.Gyro:remove() x.Parent = game.Workspace local Message = Instance.new("Hint", game.Workspace) Message.Name = "Hint" Message.Text = "A plane has crashed! Oh no!" wait(15) Message:Destroy() -- not working end function getParts(parent) for _,v in pairs(parent:GetChildren()) do if v:IsA("BasePart") and not v:IsDescendantOf(script.Parent.MainParts.LandingGear) then v.Touched:connect(function(obj) if not obj.Parent then return end if not obj.CanCollide or not v.CanCollide then return end if obj:IsDescendantOf(script.Parent) then return end if game.Players:GetPlayerFromCharacter(obj.Parent) then return end if v.Velocity.magnitude >= maxImpact then if not script.Parent.Dead.Value then crashT = time() script.Parent.Dead.Value = true game:GetService("Debris"):AddItem(script.Parent,8) delay(6, function() pcall(function() script.Parent.MainParts.MainSeat.SeatWeld:remove() end) if not explode then goBoom() end end) end end if script.Parent.Dead.Value and time() - crashT > 0.5 and not explode then goBoom() end end) end getParts(v) end end getParts(script.Parent) script.Parent.AutoCrash.Changed:connect(function() if not script.Parent.AutoCrash.Value then return end if not explode and not script.Parent.Dead.Value then crashT = time() script.Parent.Dead.Value = true game:GetService("Debris"):AddItem(script.Parent,8) goBoom() end end) |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 09:02 AM |
Now it's not crashing, and if you force it to crash by resetting or dying, it doesn't show a hint...I'll try my best to fix it
~𝓲𝓣𝓸𝓹𝓗𝓪𝓽𝓽𝓮𝓻 |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 09:18 AM |
Alright. I've decided that removing isn't going to work, so I want to make the hint say "(player) is the most recent failed pilot. Tsk tsk tsk." However, how do I detect a player's name? I've tried using
x = script.Parent.Parent.Name -- script.Parent.Parent is actually the player
However, hints dont support this, so how do I get it to say the player's name?
~𝓲𝓣𝓸𝓹𝓗𝓪𝓽𝓽𝓮𝓻 |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 10 Jun 2012 09:24 AM |
> hints dont support this
I have no idea what you mean. If you have the players name, you can definitely set a hint's message to it. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 09:30 AM |
No, I want whoever crashed the plane's name. It could be anyone.
I mean if I get the player's name like
script.Parent.Parent.Name = x
if I put "x crashed the plane", it literally appears as "x crashed the plane" not "(player) crashed the plane"
~𝓲𝓣𝓸𝓹𝓗𝓪𝓽𝓽𝓮𝓻 |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 10 Jun 2012 09:35 AM |
Oh. You need the concatenation operator, `..`:
hint.Text = script.Parent.Parent.Name .. " crashed the plane"
Or option two, `string.format`:
hint.Text = ("%s crashed the plane"):format(script.Parent.Parent.Name) |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 09:40 AM |
Thanks! It works!
~𝓲𝓣𝓸𝓹𝓗𝓪𝓽𝓽𝓮𝓻 |
|
|
| Report Abuse |
|
|