#How can I make this touched event fire every 0.1 seconds

1 messages · Page 1 of 1 (latest)

wide heath
#

What do you mean>

#

If it touches it runs a code that runs every 0.1s?

stone fulcrum
#

How can I make this touched event fire every 0.1 seconds

wide heath
#

change a value I guess

#
local touching = false
Beam.Touched:Connect(function() touching = true end)
Beam.TouchEnded:Connect(function() touching = false end)

while touching do
  -- code
end```
gusty tundra
#

i'd write it similarly, here's my example

local function touchingUpdate()
  --code
end

local touching = false
local function setIsTouching( bool )
  if bool and touching ~= bool then
    while touching do
      task.wait(0.1)
      touchingUpdate()
    end
  end
  touching = bool
end

Beam.Touched:Connect(function() setIsTouching( true ) end)
Beam.TouchEnded:Connect(function() setIsTouching( false ) end)
#

hmm nvm humanoid's touched does the same

#

you'll have to do that regardless

#

So you'll have to keep track of which limbs are in contact with Beam