while task.wait() do
if cg and root then
local origin = cg.Position
local lookAtPoint = (root.CFrame * CFrame.new(0, 0, -1)).Position
cg.CFrame = CFrame.lookAt(origin, lookAtPoint)
end
end
also, im pretty sure the first one doesn’t work and just goes to near spawn sometimes it works
(random spinning)
local plr = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DashEvent = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("DashEvent")
local Dash_Normal = 20
local Dash_Timeout = 0.15
local Can_Dash = false
local char = script.Parent
local UIS = game:GetService("UserInputService")
local leftDashKey = Enum.KeyCode.A
local rightDashKey = Enum.KeyCode.D
local forwardDashKey = Enum.KeyCode.Q
local maxDelay = 0.25
local t1 = 0
local t2 = 0
local t3 = 0
local onlyW = game.ReplicatedStorage.OnlyW.Value
local CoolingDown = false
function DashForward(root,key)
local character = root.Parent
DashEvent:FireServer(character,root,tostring(key))
end
UIS.InputBegan:Connect(function (input, gp)
local RootPart = char:FindFirstChild("HumanoidRootPart")
if CoolingDown then return end
if not RootPart then return end
if gp then return end
if input.KeyCode == leftDashKey then
if tick() - t1 <= maxDelay and onlyW == false then
CoolingDown = true
DashForward(RootPart,"A")
CoolingDown = false
else
t1 = tick()
end
end
if input.KeyCode == rightDashKey then
if tick() - t2 <= maxDelay and onlyW == false then
CoolingDown = true
DashForward(RootPart,"D")
CoolingDown = false
else
t2 = tick()
end
end
if input.KeyCode == forwardDashKey then
if tick() - t3 <= maxDelay then
CoolingDown = true
DashForward(RootPart,"W")
CoolingDown = false
else
t3 = tick()
end
end
end)
DashEvent.OnClientEvent:Connect(function(cg,root)
while task.wait() do
if cg and root then
local alignPos, alignRot = cg:WaitForChild("AlignPosition"), cg:WaitForChild("AlignOrientation")
local origin = cg.Position
--//Offset in front of player's torso (relative to look direction)
local targetPosition = (root.CFrame * CFrame.new(0, 0, -1)).Position
--//Construct new CFrame to find the rotation the part should be set to
local targetRotation = CFrame.lookAt(origin, targetPosition)
--//Move object towards position in front of character's torso, and update rotation.
alignPos.Position = targetPosition
alignRot.CFrame = targetRotation
end
end
end)