|
| 10 Jun 2013 08:28 PM |
When a player touches the brick, he is lifted up into the air, and to the side. It works fine, but it breaks whenever something besides the player touches the brick, like a hat or an item they're holding. Does anyone know how to fix this?
local enabled = false debounce = true function onTouched(part) if not enabled then enabled = true script.Parent.BrickColor = BrickColor.new("Really red") wait() script.Parent.Smoke.Enabled = true if part.Parent ~= nil then local h = part.Parent:FindFirstChild("Humanoid") if h ~= nil and debounce == true then debounce = false p = Instance.new("BodyPosition") p.Parent = part.Parent.Torso p.maxForce = Vector3.new(90000,90000,90000) p.position = part.Parent.Torso.Position + Vector3.new(0,25,0) wait(0.4) p.position = part.Parent.Torso.Position + Vector3.new(0,0,-14) wait(0.4) p:Remove() script.Parent.Smoke.Enabled = false script.Parent.BrickColor = BrickColor.new("Black") enabled = false debounce = true end end end end script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
SparkyMac
|
  |
| Joined: 27 Jul 2012 |
| Total Posts: 1863 |
|
|
| 10 Jun 2013 08:33 PM |
| I think its because the script only knows about humanoid. If it find something else then a humanoid it will bug out. I think you should make a script that makes it recognize stuff. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2013 08:34 PM |
| What would I use to make it recognize more than just humanoid? |
|
|
| Report Abuse |
|
|
SparkyMac
|
  |
| Joined: 27 Jul 2012 |
| Total Posts: 1863 |
|
|
| 10 Jun 2013 08:35 PM |
| I think it is because the script doesn't know anything else but the Humanoid.I think you need to make a script that will make the brick recognize more stuff. |
|
|
| Report Abuse |
|
|
SparkyMac
|
  |
| Joined: 27 Jul 2012 |
| Total Posts: 1863 |
|
|
| 10 Jun 2013 08:36 PM |
| You could make a scrip.t that clears all hats.So you just wont have the problem, Or you could make a script that names all hats one certain thing or everything thats not a humanoid one thing so then it will know it. |
|
|
| Report Abuse |
|
|
2unknown2
|
  |
| Joined: 30 Oct 2011 |
| Total Posts: 9351 |
|
|
| 10 Jun 2013 08:36 PM |
Capitalize position.
We are anonymous. We do not forgive. We do not forget. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2013 08:37 PM |
| It's mostly guns that are the problem, when someone jumps down from the floor above it, and the gun touches the brick. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2013 08:41 PM |
| @2unknown2, How would that fix the problem... |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 10 Jun 2013 10:25 PM |
local enabled = false debounce = true
function onTouched(part) if enabled == false then enabled = true local h = part.Parent:FindFirstChild("Humanoid") if h ~= nil and debounce == true then script.Parent.BrickColor = BrickColor.new("Really red") wait() script.Parent.Smoke.Enabled = true debounce = false p = Instance.new("BodyPosition") p.Parent = part.Parent.Torso p.maxForce = Vector3.new(90000,90000,90000) p.position = part.Parent.Torso.Position + Vector3.new(0,25,0) wait(0.4) p.position = part.Parent.Torso.Position + Vector3.new(0,0,-14) wait(0.4) p:Remove() script.Parent.Smoke.Enabled = false script.Parent.BrickColor = BrickColor.new("Black") enabled = false debounce = true end end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2013 04:57 PM |
| That made the brick not activate when a hat or gun touches it, but it still breaks it. |
|
|
| Report Abuse |
|
|
Boomboy45
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 3720 |
|
|
| 12 Jun 2013 05:20 PM |
You need to spell things EXACTLY right and that includes capitalizing all of the correct stuff, et cetera.
Run the script and tell us what the Output says.
-From the desk of the Premier of Trashcanistan |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2013 05:29 PM |
Here's the output:
script.Parent.Touched:connect(onTouched) 16:26:18.930 - local enabled = false debounce = true
function onTouched(p:29: attempt to index global 'script' (a nil value) 16:26:18.934 - Script "local enabled = false debounce = true
function onTouched(p", Line 29 16:26:18.935 - stack end |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2013 05:36 PM |
| There is nothing in the output when I touch the gun to the part (which breaks it). However, I found that once the script is broken, it is not disabled. Once I disable it, and enable it again, it works. |
|
|
| Report Abuse |
|
|
Boomboy45
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 3720 |
|
|
| 12 Jun 2013 05:51 PM |
I'm not at this level of scripting yet. Sorry mate.
-From the desk of the Premier of Trashcanistan |
|
|
| Report Abuse |
|
|
| |
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 12 Jun 2013 06:18 PM |
local d={} script.Parent.Touched:connect(function(c) c=game:GetService'Players':GetPlayerFromCharacter(c.Parent)or game:GetService'Players':GetPlayerFromCharacter(c.Parent.Parent) if c and not d[c.Name]then script.Parent:FindFirstChild'Smoke'.Enabled=true script.Parent.BrickColor=BrickColor.new'Really red' d[c.Name]=true c=c.Character local b=Instance.new('BodyPosition',c:FindFirstChild'Torso') b.maxForce=Vector3.new(900000,900000,900000) b.position=c:FindFirstChild'Torso'.Position+Vector3.new(0,25,0) wait(.4) b.position=c:FindFirstChild'Torso'.Position-Vector3.new(0,0,14) wait(.4) b:Destroy() script.Parent:FindFirstChild'Smoke'.Enabled=false script.Parent.BrickColor=BrickColor.new'Black' d[c.Name]=false end end) |
|
|
| Report Abuse |
|
|
| |
|
Nagrath99
|
  |
| Joined: 26 Mar 2011 |
| Total Posts: 1537 |
|
|
| 12 Jun 2013 06:33 PM |
| This scripting style is horrible. |
|
|
| Report Abuse |
|
|
|
| 12 Jun 2013 06:48 PM |
| Then why don't you try to help instead of just saying it's horrible? |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Jun 2013 08:27 PM |
I've been working on it for three hours now... Would it work if I added another script, with the same parent as the main script, and did something like:
if script.Parent.Smoke.Enabled == true then --Smoke is turned on after the part is touched anyway.
wait(1.3) --It takes almost 1.3 seconds to complete the main script.
script.Parent.Mover.Disabled = true --Mover is the name of the main script wait() script.Parent.Mover.Disabled = false --Like I said it works if I disable and re-enable it again.
end
I've tried to use these exact lines, but it didn't work. I'm a beginner scripter, so I'm assuming I may have made a small mistake.
At one time I made another script that disables it and re-enables it every 5 seconds, but if the main script was running while it was being disabled, it broke. |
|
|
| Report Abuse |
|
|
| |
|
| |
|