NoctizJoin Date: 2012-02-19 Post Count: 409 |
hitted = false
function ontouch()
if hitted == false then
hitted = true
wait(.5)
script.Parent.Anchored = false
wait(.5)
script.Parent.Transparency = 1
end
end
script.Parent.Touched:connect(ontouch)
Everything here works but it's just that when you step on it the block(s) next to it will fall too, can anyone help?
|
|
XephyricJoin Date: 2009-03-26 Post Count: 2270 |
hitted isn't a word |
|
NoctizJoin Date: 2012-02-19 Post Count: 409 |
I know... |
|
XephyricJoin Date: 2009-03-26 Post Count: 2270 |
The falling brick probably triggers the Touched Function for the other bricks you are talking about. To prevent it just check if the object that touched it has a humanoid in its parent model |
|
XephyricJoin Date: 2009-03-26 Post Count: 2270 |
function ontouch(hit)
if hitted == false and hit.Parent:findFirstChild("Humanoid") then |
|
UncleTazJoin Date: 2009-08-19 Post Count: 12795 |
Yea touched events trigger touch interest and that effects all bricks. |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
This could work.
~~~~~~~~~~~~~~~~~~~~~
hitted = false
script.Parent:connect(function(hit)
if hitted == true then return end
hitted = true
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
wait(.5)
script.Parent.Anchored = false
wait(.5)
script.Parent.Transparency = 1
end
hitted = false
end)
~~~~~~~~~~~~~~~~~~~~~ |
|
NoctizJoin Date: 2012-02-19 Post Count: 409 |
Still No |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
Wait, so what's the problem SPECIFICALLY. You're OP didn't really make any sense. |
|
smiley599Join Date: 2010-01-23 Post Count: 21869 |
Try this. Your script doesn't really make sense though.
~~~~~~~~~~~~~~~~~~~~~
hitted = false
script.Parent:connect(function(hit)
if hitted == false then return end
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
hitted=true
wait(.5)
script.Parent.Anchored = false
wait(.5)
script.Parent.Transparency = 1
end
hitted = false
end)
~~~~~~~~~~~~~~~~~~~~~
|
|
UncleTazJoin Date: 2009-08-19 Post Count: 12795 |
Space the bricks out by 0.05 studs. So they don't touch each other. |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
@smiley,
wouldn't that script not run, because hitted was already set to false? |
|
smiley599Join Date: 2010-01-23 Post Count: 21869 |
Sorry. Ignore what I said.
I looked at yours and saw 'if hitted==true then' and I thought the reason OP so frustratingly said 'didn't work' was because true should have been false. My mistake.
Why would you use 'then return end' though? Just use the opposite bool. |
|
XephyricJoin Date: 2009-03-26 Post Count: 2270 |
OP never said it didn't work |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
OP says it works, but not the way it's intended to. I'm assuming this script is for a model that has several parts within it, and once the player steps on a part within the model, the part de-anchors and drops. |
|
NoctizJoin Date: 2012-02-19 Post Count: 409 |
@all,
I found a way that works.
Thanks for the help.
hitted = false
function ontouch()
if hitted == false then
hitted = true
wait(.5)
script.Parent.Transparency = .5
wait(.3)
script.Parent.Transparency = 1
wait(.5)
script.Parent.CanCollide = false
wait(.5)
script.Parent.Anchored = false
end
end
script.Parent.Touched:connect(ontouch)
|
|