Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 3/1/2019 free camera script by Valualty --
- -- twitter: @Valualty --
- SPEEDY_DRIFTY = 0.7 -- studs every 1/60 seconds
- x_degree = 2.5 -- degrees every 1/60 seconds
- y_degree = 1.4 -- degrees every 1/60 seconds
- plr = game.Players.LocalPlayer
- repeat
- wait()
- until plr.Character
- mouse = plr:GetMouse()
- cam = workspace.CurrentCamera
- hum = plr.Character.Humanoid
- oldspeed = hum.WalkSpeed
- run = game:GetService('RunService')
- -----------------------------------------------------------------------
- plr.PlayerScripts.CameraScript:Destroy()
- game:GetService('UserInputService').MouseBehavior = 'Default'
- game:GetService('UserInputService').MouseIconEnabled = true
- -----------------------------------------------------------------------
- screensize = cam.ViewportSize
- w,s,a,d,q,e = false,false,false,false,false,false -- position
- rr,rl,ru,rd = false,false,false,false -- rotation
- ded = false
- tog = true
- pp = Instance.new('Part')
- pp.Transparency = 1
- pp.TopSurface = 0
- pp.BottomSurface = 0
- pp.Anchored = true
- pp.CanCollide = false
- pp.Parent = cam
- ll = Instance.new('PointLight')
- ll.Range = 60
- ll.Brightness = 1
- ll.Parent = pp
- keydown = mouse.KeyDown:Connect(function(key)
- if key == 'w' then w = true end
- if key == 's' then s = true end
- if key == 'a' then a = true end
- if key == 'd' then d = true end
- if key == 'q' then q = true end
- if key == 'e' then e = true end
- if hum.Health > 0 then
- if key == string.lower('f') then
- if tog then
- tog = false
- else
- tog = true
- end
- end
- end
- end)
- keyup = mouse.KeyUp:Connect(function(key)
- if key == 'w' then w = false end
- if key == 's' then s = false end
- if key == 'a' then a = false end
- if key == 'd' then d = false end
- if key == 'q' then q = false end
- if key == 'e' then e = false end
- end)
- died = hum.Died:Connect(function()
- ded = true
- end)
- mousemove = mouse.Move:Connect(function()
- x = mouse.X
- y = mouse.Y
- if x / screensize.X <= 0.1 then
- rl = true
- else
- rl = false
- end
- if x / screensize.X >= 0.8 then
- rr = true
- else
- rr = false
- end
- if y / screensize.Y <= 0.15 then
- ru = true
- else
- ru = false
- end
- if y / screensize.Y >= 0.8 then
- rd = true
- else
- rd = false
- end
- end)
- while ded == false do
- if tog == true then
- cam.CameraType = 'Scriptable'
- cam.CameraSubject = pp
- pp.CFrame = cam.CFrame
- hum.WalkSpeed = 0
- if w then
- cam.CFrame = cam.CFrame * CFrame.new(0,0,-SPEEDY_DRIFTY)
- end
- if s then
- cam.CFrame = cam.CFrame * CFrame.new(0,0,SPEEDY_DRIFTY)
- end
- if a then
- cam.CFrame = cam.CFrame * CFrame.new(-SPEEDY_DRIFTY,0,0)
- end
- if d then
- cam.CFrame = cam.CFrame * CFrame.new(SPEEDY_DRIFTY,0,0)
- end
- if q then
- cam.CFrame = cam.CFrame * CFrame.new(0,-SPEEDY_DRIFTY,0)
- end
- if e then
- cam.CFrame = cam.CFrame * CFrame.new(0,SPEEDY_DRIFTY,0)
- end
- -- WORKS IN FIRST TRY --
- -- rotating is in global --
- if rl then
- camrot = cam.CFrame - cam.CFrame.p
- cam.CFrame = CFrame.new(cam.CFrame.p) * CFrame.Angles(0, math.rad(x_degree), 0) * camrot
- end
- if rr then
- camrot = cam.CFrame - cam.CFrame.p
- cam.CFrame = CFrame.new(cam.CFrame.p) * CFrame.Angles(0, math.rad(-x_degree), 0) * camrot
- end
- -- rotating x can't be in global --
- if ru then
- cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(y_degree), 0, 0)
- end
- if rd then
- cam.CFrame = cam.CFrame * CFrame.Angles(math.rad(-y_degree), 0, 0)
- end
- else
- hum.WalkSpeed = oldspeed
- cam.CameraType = 'Custom'
- cam.CameraSubject = hum
- end
- run.RenderStepped:Wait()
- end
- keydown:Disconnect()
- keyup:Disconnect()
- died:Disconnect()
- mousemove:Disconnect()
- pp:Destroy()
- cam.CameraType = 'Custom'
- cam.CameraSubject = hum
Add Comment
Please, Sign In to add comment