Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would i tween:Cancel() when i hit the ground?

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

0

:Stop() ?

0

No ^

2 answers

So I'm just going to provide code that you'd paste in where your comment is.

All you would do is

local hitbox = your hitbox
hitbox.Touched:Wait()
tween:Cancel()

It's literally that simple.

2 comments

0

this might be a different problem but I've already tried something like that and when I try it it just completely stops my script from working

0

That is a different problem then because I've tested this and it does work

You could use the FloorMaterial property of the Humanoid.

if not Humanoid.FloorMaterial == Enum.Material.Air then
--If the player is not in the air, then they are physically touching something
     tween:Cancel()
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.