Hi! I’m trying to make a thing that plays an animation and changes the gravity while the player is touching a part, but it fires the TouchEnded event when you move randomly. I’m not really sure how to fix this.
local touchinghums = require(game.ReplicatedStorage.touching)
script.Parent.Touched:Connect(function(hit)
if hit.ClassName == "Accessory" then
else
local Humanoid = hit.Parent:WaitForChild("Humanoid")
if Humanoid then
touchinghums[Humanoid] = true
game.Players:GetPlayerFromCharacter(hit.Parent).falling.Value = true
local fallanim = script.Parent.fall
local track = Humanoid:LoadAnimation(fallanim)
track:Play()
end
end
end)
script.Parent.TouchEnded:Connect(function(hit)
local Humanoid = hit.Parent:WaitForChild("Humanoid")
if Humanoid then
touchinghums[Humanoid] = nil
game.Players:GetPlayerFromCharacter(hit.Parent).falling.Value = false
for i,v in pairs(Humanoid:GetPlayingAnimationTracks()) do
v:Stop()
end
end
end)