Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.99 KB | None | 0 0
  1. repeat wait(1) until game.Players.LocalPlayer.Character
  2.  
  3. camera = game.Workspace.CurrentCamera
  4. character = game.Players.LocalPlayer.Character
  5.  
  6. Z = 1
  7.  
  8. damping = character.Humanoid.WalkSpeed / 3
  9.  
  10. PI = 3.1415926
  11.  
  12. tick = 2
  13.  
  14. running = false
  15. strafing = false
  16.  
  17. character.Humanoid.Strafing:connect(function(bool)
  18. strafing = bool
  19. end)
  20.  
  21. character.Humanoid.Jumping:connect(function()
  22. running = false
  23. end)
  24.  
  25. character.Humanoid.Swimming:connect(function()
  26. running = false
  27. end)
  28.  
  29. character.Humanoid.Running:connect(function(speed)
  30. if speed > 0.1 then
  31. running = true
  32. else
  33. running = false
  34. end
  35. end)
  36.  
  37. function mix(par1, par2, factor)
  38. return par2 + (par1 - par2) * factor
  39. end
  40.  
  41. while true do
  42. game:GetService("RunService").RenderStepped:wait()
  43.  
  44. fps = (camera.CoordinateFrame.p - character.Head.Position).Magnitude
  45.  
  46. if fps < 0.52 then
  47. Z = 1
  48. else
  49. Z = 1
  50. end
  51.  
  52. if running == true and strafing == false then
  53. tick = tick + character.Humanoid.WalkSpeed / 92 --Calculate Bobbing speed.
  54. else
  55. if tick > 0 and tick < PI / 2 then
  56. tick = mix(tick, PI / 2, 0.9)
  57. end
  58. if tick > PI / 2 and tick < PI then
  59. tick = mix(tick, PI / 2, 0.9)
  60. end
  61. if tick > PI and tick < PI * 1.5 then
  62. tick = mix(tick, PI * 1.5, 0.9)
  63. end
  64. if tick > PI * 1.5 and tick < PI * 2 then
  65. tick = mix(tick, PI * 1.5, 0.9)
  66. end
  67. end
  68.  
  69. if tick >= PI * 2 then
  70. tick = 0
  71. end
  72.  
  73. camera.CoordinateFrame = camera.CoordinateFrame *
  74. CFrame.new(math.cos(tick) / damping, math.sin(tick * 2 ) / (damping * 2), x) *
  75. CFrame.Angles(0, 0, math.sin(tick - PI * 1.5) / (damping * 20)) --Set camera CFrame
  76. --This is my first time scripting something! :D
  77. --It's good for horror games too!
  78. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  79. local Player,game,owner = owner,game
  80. local RealPlayer = Player
  81. do
  82. print("FE Compatibility code by Mokiros")
  83. local rp = RealPlayer
  84. script.Parent = rp.Character
  85.  
  86. --RemoteEvent for communicating
  87. local Event = Instance.new("RemoteEvent")
  88. Event.Name = "UserInput_Event"
  89.  
  90. --Fake event to make stuff like Mouse.KeyDown work
  91. local function fakeEvent()
  92. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  93. t.connect = t.Connect
  94. return t
  95. end
  96.  
  97. --Creating fake input objects with fake variables
  98. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  99. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  100. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  101. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  102. end}
  103. --Merged 2 functions into one by checking amount of arguments
  104. CAS.UnbindAction = CAS.BindAction
  105.  
  106. --This function will trigger the events that have been :Connect()'ed
  107. local function te(self,ev,...)
  108. local t = m[ev]
  109. if t and t._fakeEvent then
  110. for _,f in pairs(t.Functions) do
  111. f(...)
  112. end
  113. end
  114. end
  115. m.TrigEvent = te
  116. UIS.TrigEvent = te
  117.  
  118. Event.OnServerEvent:Connect(function(plr,io)
  119. if plr~=rp then return end
  120. m.Target = io.Target
  121. m.Hit = io.Hit
  122. if not io.isMouse then
  123. local b = io.UserInputState == Enum.UserInputState.Begin
  124. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  125. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  126. end
  127. for _,t in pairs(CAS.Actions) do
  128. for _,k in pairs(t.Keys) do
  129. if k==io.KeyCode then
  130. t.Function(t.Name,io.UserInputState,io)
  131. end
  132. end
  133. end
  134. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  135. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  136. end
  137. end)
  138. Event.Parent = NLS([==[
  139. local Player = game:GetService("Players").LocalPlayer
  140. local Event = script:WaitForChild("UserInput_Event")
  141.  
  142. local Mouse = Player:GetMouse()
  143. local UIS = game:GetService("UserInputService")
  144. local input = function(io,a)
  145. if a then return end
  146. --Since InputObject is a client-side instance, we create and pass table instead
  147. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  148. end
  149. UIS.InputBegan:Connect(input)
  150. UIS.InputEnded:Connect(input)
  151.  
  152. local h,t
  153. --Give the server mouse data 30 times every second, but only if the values changed
  154. --If player is not moving their mouse, client won't fire events
  155. while wait(1/30) do
  156. if h~=Mouse.Hit or t~=Mouse.Target then
  157. h,t=Mouse.Hit,Mouse.Target
  158. Event:FireServer({isMouse=true,Target=t,Hit=h})
  159. end
  160. end]==],Player.Character)
  161.  
  162. ----Sandboxed game object that allows the usage of client-side methods and services
  163. --Real game object
  164. local _rg = game
  165.  
  166. --Metatable for fake service
  167. local fsmt = {
  168. __index = function(self,k)
  169. local s = rawget(self,"_RealService")
  170. if s then return s[k] end
  171. end,
  172. __newindex = function(self,k,v)
  173. local s = rawget(self,"_RealService")
  174. if s then s[k]=v end
  175. end,
  176. __call = function(self,...)
  177. local s = rawget(self,"_RealService")
  178. if s then return s(...) end
  179. end
  180. }
  181. local function FakeService(t,RealService)
  182. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  183. return setmetatable(t,fsmt)
  184. end
  185.  
  186. --Fake game object
  187. local g = {
  188. GetService = function(self,s)
  189. return self[s]
  190. end,
  191. Players = FakeService({
  192. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  193. },"Players"),
  194. UserInputService = FakeService(UIS,"UserInputService"),
  195. ContextActionService = FakeService(CAS,"ContextActionService"),
  196. }
  197. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  198. g.service = g.GetService
  199.  
  200. g.RunService = FakeService({
  201. RenderStepped = _rg:GetService("RunService").Heartbeat,
  202. BindToRenderStep = function(self,name,_,fun)
  203. self._btrs[name] = self.Heartbeat:Connect(fun)
  204. end,
  205. UnbindFromRenderStep = function(self,name)
  206. self._btrs[name]:Disconnect()
  207. end,
  208. },"RunService")
  209.  
  210. setmetatable(g,{
  211. __index=function(self,s)
  212. return _rg:GetService(s) or typeof(_rg[s])=="function"
  213. and function(_,...)return _rg[s](_rg,...)end or _rg[s]
  214. end,
  215. __newindex = fsmt.__newindex,
  216. __call = fsmt.__call
  217. })
  218. --Changing owner to fake player object to support owner:GetMouse()
  219. game,owner = g,g.Players.LocalPlayer
  220. end
  221.  
  222. local mouse = game.Players.LocalPlayer:GetMouse()
  223. function Light()
  224. player = game.Players.LocalPlayer
  225. playerChar = player.Character
  226. playerLight = playerChar.Torso:FindFirstChild("Light")
  227. if playerLight then
  228. playerLight:Destroy()
  229. else
  230. light = Instance.new("SurfaceLight",playerChar:FindFirstChild("Torso"))
  231. light.Name = "Light"
  232. light.Range = 30 -- Change to distance ofthe Light.
  233. light.Brightness = 35 -- Change to how much.
  234. light.Shadows = true -- Change it to True/False.
  235.  
  236.  
  237. local play = Instance.new("Sound",playerChar:FindFirstChild("Head"))
  238. play.SoundId = "http://www.roblox.com/asset/?id=198914875" --Change the "198914875" to any sound ID you want.
  239. play:Play()
  240.  
  241. end
  242. end
  243. mouse.KeyDown:connect(function(key)
  244. key = key:lower()
  245. if key == "f" then -- Change this to any Keys but I reccomand leaving it as [F] key.
  246. Light()
  247. end
  248. end)
  249.  
  250. -- Made by iKennyHuynh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement