|
| 24 Jun 2016 01:42 PM |
script.Parent.Touched:connect(function(h) if h.Parent:FindFirstChild("Humanoid") then script.Parent.Transparency = 0 end end)
script.Parent.TouchEnded:connect(function(h) if h.Parent:FindFirstChild("Humanoid") then script.Parent.Transparency = 1 end end)
I want it so when you are still touching the brick the transparency will be 0, but even the slightest movement triggers touch ended..
|
|
|
| Report Abuse |
|
|
Inigo18
|
  |
| Joined: 02 Feb 2014 |
| Total Posts: 1041 |
|
|
| 24 Jun 2016 01:46 PM |
local a = false local b = false
script.Parent.Touched:connect(function(h) if h.Parent:FindFirstChild("Humanoid") then if a == false then a = true script.Parent.Transparency = 0 end end end wait(3) b = true end)
script.Parent.TouchEnded:connect(function(h) if h.Parent:FindFirstChild("Humanoid") then if b == true then script.Parent.Transparency = 1 end end a = false b = false end) |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2016 01:48 PM |
Expectend ) to close ( at line 4 instead got wait
|
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 24 Jun 2016 01:50 PM |
then fix it
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2016 01:52 PM |
trying to, but it doesn't go back to 1 transparency
|
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 24 Jun 2016 01:58 PM |
There's an extra end in the first bit of code
|
|
|
| Report Abuse |
|
|
|
| 24 Jun 2016 01:59 PM |
when I remove it, it still doesn't work
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 24 Jun 2016 01:59 PM |
"it"
which one
Also this is not the best way to debounce this
|
|
|
| Report Abuse |
|
|
|
| 24 Jun 2016 01:59 PM |
when I touch the brick the transparency goes to 0 but when I stop, it doesn't revert back to 1
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 24 Jun 2016 02:03 PM |
debounce = true
script.Parent.Touched:connect(function(h) if debounce then return end debounce = false if h.Parent:FindFirstChild("Humanoid") then script.Parent.Transparency = 0 end script.Parent.TouchedEnded:connect(function(h) if h.Parent:FindFirstChild("Humanoid") then script.Parent.Transparency = 1 debounce = true end end) end)
-- try this?
|
|
|
| Report Abuse |
|
|
|
| 24 Jun 2016 02:03 PM |
the second part, the brick goes visible when u touch it but when ur not touching it, it should be invisible but it isn't.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 24 Jun 2016 02:06 PM |
this maybe?
debounce = true
script.Parent.Touched:connect(function(h) if debounce then return end if h.Parent:FindFirstChild("Humanoid") then debounce = false script.Parent.Transparency = 0 end end)
script.Parent.TouchedEnded:connect(function(h) if h.Parent:FindFirstChild("Humanoid") then debounce = true script.Parent.Transparency = 1 end end)
|
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 24 Jun 2016 02:07 PM |
Oh Haha! Debounce gets confused in my brain. I just messed them up is all:
debounce = false
script.Parent.Touched:connect(function(h) if debounce then return end if h.Parent:FindFirstChild("Humanoid") then debounce = true script.Parent.Transparency = 0 end end)
script.Parent.TouchedEnded:connect(function(h) if h.Parent:FindFirstChild("Humanoid") then debounce = false script.Parent.Transparency = 1 end end)
|
|
|
| Report Abuse |
|
|
|
| 24 Jun 2016 02:08 PM |
That works up until a point, I touch the brick, it turns visible, I stop touching the brick, it's still visible when it should be invisible.
|
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 24 Jun 2016 02:10 PM |
it's TouchEnded not TouchedEnded
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 24 Jun 2016 02:11 PM |
--Distance of vectors for the win! script.Parent.Touched:connect(function(hit) while (hit.Position - script.Parent.Position).Magnitude <= script.Parent.Size.Magnitude do wait(0.3) script.Parent.Transparency = 0 end script.Parent.Transparency = 1 end) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 24 Jun 2016 02:13 PM |
Either magnitude or GetTouchingParts()
|
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 24 Jun 2016 02:14 PM |
--Faster response time: script.Parent.Touched:connect(function(hit) while (hit.Position - script.Parent.Position).Magnitude <= script.Parent.Size.Magnitude do script.Parent.Transparency = 0 wait(0.3) end script.Parent.Transparency = 1 end) |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2016 02:14 PM |
Dev that didn't work, it turned visible but not invisible.
btw I fixed it so it was TouchEnded, it worked but, it's still not smooth and if you run across the wall it starts blinking visible/invisible
|
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 24 Jun 2016 02:16 PM |
| Just tested, it works fine. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 24 Jun 2016 02:17 PM |
Maybe a higher delay. script.Parent.Touched:connect(function(hit) while (hit.Position - script.Parent.Position).Magnitude <= script.Parent.Size.Magnitude do script.Parent.Transparency = 0 wait(0.5) end script.Parent.Transparency = 1 end) |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 24 Jun 2016 02:17 PM |
TouchEnded* apparently
Could it be better to disconnect?
debounce = true
function Touch(hit) if hit.Parent:FindFirstChild("Humanoid") then connectionTouched:Disconnect() debounce = false script.Parent.Transparency = 0 end end
function TouchEnded(hit) if debounce == false then if hit.Parent:FindFirstChild("Humanoid") then script.Parent.Transparency = 1 wait(3) debounce = true connectionTouched = script.Parent.Touched:connect(Touched) end end end
connectionTouched = script.Parent.Touched:connect(Touched) connectionTouchEnded = script.Parent.TouchEnded:connect(TouchedEnded)
|
|
|
| Report Abuse |
|
|
|
| 24 Jun 2016 02:18 PM |
I'm using a normal brick, put the script in it, I touched it, became visible.
Moved away still visible but it should be invisible. What happened to u
|
|
|
| Report Abuse |
|
|