I don’t want the character to cross objects or “shake” madly by spinning, flying etc, making the camera as crazy as he is, he will go up and down mountains with that speed, I want to do exactly like this game Friday the 13th: The Game.
local uis = game:GetService('UserInputService')
local db = false
local event = script:WaitForChild("RemoteEvent")
local pressed = false
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.ChildAdded:Wait()
local root = char:FindFirstChild("HumanoidRootPart")
local hum = char:FindFirstChild('Humanoid')
local cooldown = 10
local nowCol = 0
local ts = game:GetService("TweenService")
local tween = ts:Create(script.Parent.Fill, TweenInfo.new(cooldown), {ImageTransparency = .3})
uis.InputBegan:Connect(function(key, inputing)
if key.KeyCode == Enum.KeyCode.Three then
if hum:GetAttribute('Occupied') == true or hum:GetAttribute('Stunned') == true then return end
if db == false and nowCol <= 0 then
event:FireServer(false)
db = true
pressed = true
BV=Instance.new('BodyVelocity', root)
BV.MaxForce=Vector3.new(math.huge,0,math.huge)
script.Parent.Fill.ImageTransparency = 1
script.Parent.Parent.Parent.Parent.Background.Ab3.Visible = false
task.spawn(function()
wait(5)
if pressed then
pressed = false
nowCol = cooldown
BV:Destroy()
event:FireServer(true)
end
end)
task.spawn(function()
while pressed do
wait(.1)
BV.Velocity=root.CFrame.lookVector*100
end
end)
end
end
end)
uis.InputEnded:Connect(function(key, inputing)
if key.KeyCode == Enum.KeyCode.Three then
if pressed == true then
pressed = false
nowCol = cooldown
BV:Destroy()
event:FireServer(true)
end
end
end)
task.spawn(function()
while wait(1) do
if nowCol > 0 then
nowCol = nowCol-1
tween:Play()
tween.Completed:Connect(function(playbackState)
if playbackState == Enum.PlaybackState.Completed then
script.Parent.Parent.Parent.Parent.Background.Ab3.Visible = true
db = false
end
end)
end
end
end)