For 2-3 days (I’ve lost count lol) I have been making a dash script for an RPG game i’m working on. (Although it DID take like 2 posts to help me script it)
This is the final hitch until it’s done.
local UIS = game:GetService("UserInputService") --Eh its all varibles
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://7258476516"
local keybind = Enum.KeyCode.Q-- between the key for ability
local TP = game.Workspace.TriggerParts.DashCollision
local canslide = true -- can I dash?
UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end
if input.KeyCode == keybind then
if TP.Transparency == 0 then -- first it checks that your hitbox isnt touching anything
if canslide == true then -- is it pressed?
canslide = false -- no spamming
local playAnim = char.Humanoid:LoadAnimation(slideAnim) --load the anim
playAnim:Play() --play the anim
canslide = false -- more stuff to ensure no spam
local TweenService = game:GetService('TweenService')
local TweenInfo = TweenInfo.new(0.5) -- Creating a TweenInfo for our tween later. Usually, it's formatted like this: TweenInfo.new(time, EasingStyle, EasingDirection, count, repeat, delay).
local HumanoidRootPart = char.HumanoidRootPart -- The root part that melds guy together, therefore dragging them
local newCFrame = HumanoidRootPart.CFrame * CFrame.new(0, 0, -25) -- the thingy for what direction. Y is up/down why am i typing this I already know it
HumanoidRootPart.Anchored = true -- Stopping the character from moving.
canslide = false -- more stuff to ensure no spam
local Tween = TweenService:Create(HumanoidRootPart, TweenInfo, {CFrame = newCFrame}) -- Creates the tween using those coords
while TP.Transparency == 0.1 do
wait(0.01)
Tween:Cancel()
end
Tween:Play() -- makes us move
canslide = false -- more stuff to ensure no spam
-- waits until dash is done
HumanoidRootPart.Anchored = false -- allows us out of dash
end
wait(1.5) -- cooldown to prevent hovering
canslide = true -- cooldown is done!
end
end
end)
So pretty much this system uses a few scripts
- The dash script, which is what the above is
- The hitboxconfiguration-inator. This script is 100% done and needs no work.
- Hitbox hit detector. This script detects when the hitbox collides with a part, and sets what I refer to as a trigger part’s transparency. This allows other scripts to use that part’s data to influence itself.
So that’s a simple explanation. If you need anymore just ask me.
Pretty much the goal is to use that hitboxes collision data to stop the tween. I’ve tried this a few times, and don’t know how.
I don’t know, I haven’t done this, but…
What if you set up a connection to the transparency property of the TP part and have that kick off a function to do a tween:Pause? I think if you :cancel the tween mid dash, you’ll get put back to where you started which would be weird looking. You might have to make your tween variable outside the function its in now, so you can access it from the property :connect. Then maybe do a check to see if the tween is playing and if it is, :pause it. IDK, good luck.
for the property thing, check this:
https://developer.roblox.com/en-us/api-reference/function/Instance/GetPropertyChangedSignal
Thanks for the suggestions! Unfortunately functions make the variables go screwy. Tween:Pause, is also the mid-dash problem so I think that’s good.
this is as far as i’ve gotten.
Tween:Play() -- makes us move
wait(0.1)
if TP.Transparency == 0.1 then Tween:Cancel() else end
wait(0.1)
if TP.Transparency == 0.1 then Tween:Cancel() else end
wait(0.1)
if TP.Transparency == 0.1 then Tween:Cancel() else end
wait(0.1)
if TP.Transparency == 0.1 then Tween:Cancel() else end
wait(0.1)
if TP.Transparency == 0.1 then Tween:Cancel() else end
I know this looks really bad as a script, but I think it’s really the only way. The dash naturally ends after 0.5 seconds, and loops (even function loops) just don’t work for this.
So something like this wouldn’t work?:
checkTP = TP:GetPropertyChangedSignal("Transparency"):Connect(function()
if TP.Transparency == .1 then Tween.Cancel() end
end)
Tween:Play()
checkTP:Disconnect()
Wouldn’t that monitor the TP part while the tween is playing and stop it if needed?
Sadly it doesn’t. I flopped it around a bit and the tween doesn’t cancel. I may end up using velocity instead of tween, although its not nearly as visually appealing.
Should I switch or keep going? Either way thanks for trying to help.
I did it. It took one google search and I am in excruciating pain.
local UIS = game:GetService("UserInputService") --Eh its all varibles
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
local keybind = Enum.KeyCode.Q-- between the key for ability
local TP = game.Workspace.TriggerParts.DashCollision
local canslide = true -- can I dash?
local collide = false
local press = false
-- Creating a TweenInfo for our tween later. Usually, it's formatted like this: TweenInfo.new(time, EasingStyle, EasingDirection, count, repeat, delay).
local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://7258476516"
if TP.Transparency == 0.1 then collide = true
if TP.Transparency == 0 then collide = false
end
end
UIS.InputBegan:Connect(function(input,gameprocessed)
if gameprocessed then return end
if not canslide then return end
if input.KeyCode == keybind then
if TP.Transparency == 0 then -- first it checks that your hitbox isnt touching anything
if canslide == true then
-- is it pressed?
canslide = false
press = true
local HRP = char.HumanoidRootPart -- The root part that melds guy together, therefore dragging them
HRP.Anchored = true -- Stopping the character from moving.
canslide = false -- more stuff to ensure no spam
local playAnim = char.Humanoid:LoadAnimation(slideAnim) --load the anim
playAnim:Play() --play the anim
HRP.Velocity = HRP.Velocity + HRP.CFrame.lookVector*100 -- This makes the velocity of the character's Root Part 100 in the direction it's facing, so it would move the character forward
press = false
canslide = false -- more stuff to ensure no spam
-- waits until dash is done
local HumanoidRootPart = char.HumanoidRootPart
HumanoidRootPart.Anchored = false -- allows us out of dash
-- more stuff to ensure no spam
end
wait(1.5) -- cooldown to prevent hovering
canslide = true -- cooldown is done!
end
end
end)
What is the animation priority movement set to?
Action. So pretty much it overrides all other ones.