Advertisement
cat568

Untitled

Jan 23rd, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. --just put this on the top of a script and boom 89% works
  3. --note this does not work on big scripts
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,game,owner = owner,game
  6. local RealPlayer = Player
  7. do
  8.     local rp = RealPlayer
  9.     script.Parent = rp.Character
  10.    
  11.     --RemoteEvent for communicating
  12.     local Event = Instance.new("RemoteEvent")
  13.     Event.Name = "UserInput_Event"
  14.  
  15.     --Fake event to make stuff like Mouse.KeyDown work
  16.     local function fakeEvent()
  17.         local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  18.         t.connect = t.Connect
  19.         return t
  20.     end
  21.  
  22.     --Creating fake input objects with fake variables
  23.     local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  24.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  25.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  26.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  27.     end}
  28.     --Merged 2 functions into one by checking amount of arguments
  29.     CAS.UnbindAction = CAS.BindAction
  30.  
  31.     --This function will trigger the events that have been :Connect()'ed
  32.     local function te(self,ev,...)
  33.         local t = m[ev]
  34.         if t and t._fakeEvent then
  35.             for _,f in pairs(t.Functions) do
  36.                 f(...)
  37.             end
  38.         end
  39.     end
  40.     m.TrigEvent = te
  41.     UIS.TrigEvent = te
  42.  
  43.     Event.OnServerEvent:Connect(function(plr,io)
  44.         if plr~=rp then return end
  45.         m.Target = io.Target
  46.         m.Hit = io.Hit
  47.         if not io.isMouse then
  48.             local b = io.UserInputState == Enum.UserInputState.Begin
  49.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  50.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  51.             end
  52.             for _,t in pairs(CAS.Actions) do
  53.                 for _,k in pairs(t.Keys) do
  54.                     if k==io.KeyCode then
  55.                         t.Function(t.Name,io.UserInputState,io)
  56.                     end
  57.                 end
  58.             end
  59.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  60.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  61.         end
  62.     end)
  63.     Event.Parent = NLS([==[
  64.     local Player = game:GetService("Players").LocalPlayer
  65.     local Event = script:WaitForChild("UserInput_Event")
  66.  
  67.     local Mouse = Player:GetMouse()
  68.     local UIS = game:GetService("UserInputService")
  69.     local input = function(io,a)
  70.         if a then return end
  71.         --Since InputObject is a client-side instance, we create and pass table instead
  72.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  73.     end
  74.     UIS.InputBegan:Connect(input)
  75.     UIS.InputEnded:Connect(input)
  76.  
  77.     local h,t
  78.     --Give the server mouse data 30 times every second, but only if the values changed
  79.     --If player is not moving their mouse, client won't fire events
  80.     while wait(1/30) do
  81.         if h~=Mouse.Hit or t~=Mouse.Target then
  82.             h,t=Mouse.Hit,Mouse.Target
  83.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  84.         end
  85.     end]==],Player.Character)
  86.  
  87.     ----Sandboxed game object that allows the usage of client-side methods and services
  88.     --Real game object
  89.     local _rg = game
  90.  
  91.     --Metatable for fake service
  92.     local fsmt = {
  93.         __index = function(self,k)
  94.             local s = rawget(self,"_RealService")
  95.             if s then return s[k] end
  96.         end,
  97.         __newindex = function(self,k,v)
  98.             local s = rawget(self,"_RealService")
  99.             if s then s[k]=v end
  100.         end,
  101.         __call = function(self,...)
  102.             local s = rawget(self,"_RealService")
  103.             if s then return s(...) end
  104.         end
  105.     }
  106.     local function FakeService(t,RealService)
  107.         t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  108.         return setmetatable(t,fsmt)
  109.     end
  110.  
  111.     --Fake game object
  112.     local g = {
  113.         GetService = function(self,s)
  114.             return self[s]
  115.         end,
  116.         Players = FakeService({
  117.             LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  118.         },"Players"),
  119.         UserInputService = FakeService(UIS,"UserInputService"),
  120.         ContextActionService = FakeService(CAS,"ContextActionService"),
  121.     }
  122.     rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  123.     g.service = g.GetService
  124.    
  125.     g.RunService = FakeService({
  126.         RenderStepped = _rg:GetService("RunService").Heartbeat,
  127.         BindToRenderStep = function(self,name,_,fun)
  128.             self._btrs[name] = self.Heartbeat:Connect(fun)
  129.         end,
  130.         UnbindFromRenderStep = function(self,name)
  131.             self._btrs[name]:Disconnect()
  132.         end,
  133.     },"RunService")
  134.  
  135.     setmetatable(g,{
  136.         __index=function(self,s)
  137.             return _rg:GetService(s) or typeof(_rg[s])=="function"
  138.             and function(_,...)return _rg[s](_rg,...)end or _rg[s]
  139.         end,
  140.         __newindex = fsmt.__newindex,
  141.         __call = fsmt.__call
  142.     })
  143.     --Changing owner to fake player object to support owner:GetMouse()
  144.     game,owner = g,g.Players.LocalPlayer
  145. end
  146.  
  147.  
  148. --thank you for bringing this paste 1k views! :)
  149.  
  150. hint = Instance.new("Hint",workspace)
  151. nuke = Instance.new("Part",workspace)
  152. nuke.Size = Vector3.new(5,50,5)
  153. nuke.Material = Enum.Material.DiamondPlate
  154. nuke.BrickColor = BrickColor.Gray()
  155. nuke.CFrame = CFrame.new(0,10000,0)
  156. bodypos = Instance.new("BodyPosition",nuke)
  157. bodypos.MaxForce = Vector3.new(100,100,100)
  158. bodypos.D = 100
  159. bodypos.P = 5
  160. bodypos.Position = Vector3.new(0,0,0)
  161. debounce = false
  162. size = 5
  163. waittime = 0.0001
  164. hint.Text = "TACTICAL NUKE! INCOMING!"
  165. nuke.Touched:connect(function()
  166. if debounce == false then
  167. debounce = true
  168. nuke.Anchored = true
  169. boomboom = Instance.new("Part",workspace)
  170. boomboom.BrickColor = BrickColor.new("Gold")
  171. boomboom.Shape = Enum.PartType.Ball
  172. boomboom.Anchored = true
  173. boomboom.Transparency = 0.5
  174. boomboom.TopSurface = Enum.SurfaceType.Smooth
  175. boomboom.BottomSurface = Enum.SurfaceType.Smooth
  176. boomboom.CanCollide = false
  177. boomboom.CFrame = CFrame.new(0,0,0)
  178. boomboom.Touched:connect(function(hit)
  179. hit:BreakJoints()
  180. end)
  181. while true do
  182. wait(waittime)
  183. expl = Instance.new("Explosion",workspace)
  184. hint.Text = "NUKE HAS GAINED "..tostring(boomboom.Size.Y).." STUDS OF SIZE!"
  185. expl.BlastPressure = 999
  186. expl.BlastRadius = size
  187. expl.Position = Vector3.new(0,0,0)
  188. boomboom.Size = boomboom.Size + Vector3.new(size,size,size)
  189. size = size + 0.001
  190. waittime = waittime - 0.001
  191. end
  192. end
  193. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement