I am trying to make a teleport effect, it mostly works, but when someone is shift locked the model only is the way they are facing. I would like it if they teleported to the left, the model would be facing left, etc. Here’s the local script:.
wait(3)
--[[ if Player.Character:FindFirstChild("TrueDisable") then return end
if Player.Character:FindFirstChild("NoAttack") then return end
if Player.Character:FindFirstChild("Disable") then return end]]
local Player = game.Players.LocalPlayer
local Char = Player.Character
local status = Char:WaitForChild("StatusEffects")
local Root = Char.HumanoidRootPart
local Mouse = Player:GetMouse()
local canttdash = 0
status.ChildAdded:connect(function(thing)
if thing.Name == "Stun" or thing.Name == "NoDash" then
canttdash = canttdash +1
end
end)
status.ChildRemoved:connect(function(thing)
if thing.Name == "Stun" or thing.Name == "NoDash" then
wait(.15)
canttdash = canttdash -1
end
end)
local maxdashes = 5
local dashes = 5
local dashcheck = 0
local w = false
local a = false
local s = false
local d = false
local brr = false
local bfcd = false
local Ignore = {Char,game.Workspace.Players}
function ray(startpos, endpos, dis)
local test = Ray.new(startpos, CFrame.new(startpos, endpos).lookVector * dis)
local hit, pos, sf = game.Workspace:FindPartOnRayWithIgnoreList(test,Ignore)
return hit, pos, sf
end
local CAM = game.Workspace.CurrentCamera
Mouse.KeyDown:Connect(function(key)
if key == "w" then
w = true
end
if key == "a" then
a = true
brr = true
end
if key == "s" then
s = true
end
if key == "d" then
d = true
end
if key == "q" then
--local CF = CAM.CFrame*CFrame.new(0,0,8)
local LookVector = Root.CFrame
local c1 = Vector3.new(CAM.CFrame.X, Root.CFrame.Y, CAM.CFrame.Z)
local c2 = CAM.CFrame * CFrame.new(0, 0, 2)
c2 = Vector3.new(c2.X, Root.CFrame.Y, c2.Z)
local CF = Root.CFrame * CFrame.new(0,0,8)
if w then
CF = Root.CFrame * CFrame.new(0,0,-8)
end
if a then
CF = Root.CFrame * CFrame.new(-8,0,0)
end
if d then
CF = Root.CFrame * CFrame.new(8,0,0)
end
local h, p, sf = ray(Root.CFrame * CFrame.new(0,0,0).p, CF.p, 15, nil)
local CFF = CFrame.new(p.x,p.y,p.z)
local CFF2 = CFrame.new(Root.Position,Root.Position + Vector3.new(LookVector.lookVector.x,0,LookVector.lookVector.z))
local originalcf = Char.Torso.CFrame
if Char:FindFirstChild("DragonSage") then
if bfcd then return end
if canttdash > 0 then return end
if dashes <= 0 then return end
local h, p, sf = ray(Root.CFrame * CFrame.new(0,0,0).p, CF.p, 10, nil)
dashcheck = dashcheck +1
dashes = dashes -1
print("dashes = "..dashes)
spawn(function()
local lastdash = dashcheck
if lastdash == dashcheck then
dashes = maxdashes
print'dashes reset'
end
end)
bfcd = true
spawn(function()
wait(.8)
bfcd = false
end)
local pos1 = CFF.p
local pos2 = CFF2.p
local playerrot = Root.Rotation
script.BodyFlicker:FireServer({CFF, originalcf, playerrot, brr})
wait()
Root.CFrame = Player.Character.Torso.CFrame
local s = Instance.new("Sound")
s.Parent = Root
s.SoundId = "rbxassetid://517249876"
s.Volume = 1
s:Play()
wait(.15)
wait(.45)
wait(.45)
end
--Root.CFrame = CFrame.new(p.x,p.y,p.z)
--Root.CFrame = CFrame.new(Root.Position,Root.Position + Vector3.new(LookVector.lookVector.x,0,LookVector.lookVector.z))
end
end)
Mouse.KeyUp:Connect(function(key)
if key == "w" then
w = false
end
if key == "a" then
a = false
brr = false
end
if key == "s" then
s = false
end
if key == "d" then
d = false
end
end)
server script:
wait(1)
local CD = false--
script.Parent.OnServerEvent:connect(function(Player,tab)
local CFF = tab[1]
local CFF2 = tab[2]
local rot = tab[3]
local brr = tab[4]
if Player.Character:WaitForChild("StatusEffects"):FindFirstChild("TrueDisable") then return end
if Player.Character:WaitForChild("StatusEffects"):FindFirstChild("NoAttack") then return end
if Player.Character:WaitForChild("StatusEffects"):FindFirstChild("Disable") then return end
if CD then return end
if Player.Character:FindFirstChild("DragonSage") then
local COST = 5
local dsagedash = game.ServerStorage.DragonSage.Dash:Clone()
dsagedash.PrimaryPart = dsagedash.Primary
local rot2 = Player.Character.HumanoidRootPart.Rotation
Player.Character.HumanoidRootPart.CFrame = CFF
Player.Character.HumanoidRootPart.Rotation = rot2
if brr then
local rot2 = Vector3.new(0,90,0)
end
dsagedash:SetPrimaryPartCFrame(Player.Character:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0,0,10))
for i,v in pairs (dsagedash:GetChildren()) do
v.Rotation = rot2
end
dsagedash.Parent = workspace
spawn(function()
wait(.5)
dsagedash:Destroy()
end)
end
end)