I’m having trouble deciding If I want to use touched events still or use an alternative. Can anyone explain to be and answer the question of this topic?
What are you trying to use Touched
events for?
-- what do you mean by they haven’t been fixed?
I’m presuming the fact that if you stand still the Touched
event ends.
-- events aren’t continuous things though. there’s no length to them, there’s just the instant they’re fired
A lot of people say that tocuehd events are broken, and they use other alternatives
I’m detecting whenever a ball is hit.
As @skedgyedgy said they are only supposed to fire when the thing happens, in this case when the player touches the part.
To have a continuous version you can combine .Touched
with .TouchEnded
Something like this:
local plrsTouching = {}
local part = script.Parent
part.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
plrsTouching[plr.UserId] = true
repeat
print("Code")
task.wait(1)
until plrsTouching[plr.UserId] == nil
end
end)
part.TouchEnded:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
plrsTouching[plr.UserId] = nil
end
end)
The touched events used to be more stable before the PGS physics solver was introduced. Turning off the solver solves the problem, but it can only be done on older versions of studio.
I liked the previous functionality of the events before PGS.