This is a part of a dodge script for my game, what's happening in this script is the tween is what's moving me when I dodge but the problem is I can phase into the ground when I dodge, I've been trying to put something where if I touch a block the tween cancels but it wont work for me. If you have any questions please reply to this post. SCRIPT:
game.ReplicatedStorage.DownDodge.OnServerEvent:Connect(function(player)
local tweenService = game:GetService("TweenService")
local part = player.Character.HumanoidRootPart
if debounce[player.UserId] == nil then
debounce[player.UserId] = false
alreadydodged[player.UserId] = nil
counterparthappened = true
player.Character.LowerTorso.DodgeCircle.Trail.Enabled = true
player.Character.LowerTorso.DodgeCircle.Transparency = 0
player.Character.HumanoidRootPart.Anchored = true
local goal = {}
goal.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position + Vector3.new(0,-12,0)) * CFrame.Angles(0, 0, 0)
local tweenInfo = TweenInfo.new(.2)
local tween = tweenService:Create(part, tweenInfo, goal)
tween:Play()
--Cancel tween right here when block touched
wait(.2)
player.Character.LowerTorso.DodgeCircle.Transparency = 1
player.Character.HumanoidRootPart.Anchored = false
player.Character.LowerTorso.DodgeCircle.Trail.Enabled = false
wait(Time)
if alreadydodged[player.UserId] == nil then
wait(Time2)
debounce[player.UserId] = nil
else debounce[player.UserId] = nil
end
end
end)
NOTE: if you can't help me by the player touching the ground, I have a hitbox block that's located in lower torso that wraps around the player

2 comments
:Stop() ?
No ^