Advertisement
cat568

Untitled

Jan 12th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.84 KB | None | 0 0
  1. --just put this on the top of a script and boom 89% works
  2. --note this does not work on big scripts
  3. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  4. local Player,game,owner = owner,game
  5. local RealPlayer = Player
  6. do
  7. local rp = RealPlayer
  8. script.Parent = rp.Character
  9.  
  10. --RemoteEvent for communicating
  11. local Event = Instance.new("RemoteEvent")
  12. Event.Name = "UserInput_Event"
  13.  
  14. --Fake event to make stuff like Mouse.KeyDown work
  15. local function fakeEvent()
  16. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  17. t.connect = t.Connect
  18. return t
  19. end
  20.  
  21. --Creating fake input objects with fake variables
  22. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  23. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  24. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  25. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  26. end}
  27. --Merged 2 functions into one by checking amount of arguments
  28. CAS.UnbindAction = CAS.BindAction
  29.  
  30. --This function will trigger the events that have been :Connect()'ed
  31. local function te(self,ev,...)
  32. local t = m[ev]
  33. if t and t._fakeEvent then
  34. for _,f in pairs(t.Functions) do
  35. f(...)
  36. end
  37. end
  38. end
  39. m.TrigEvent = te
  40. UIS.TrigEvent = te
  41.  
  42. Event.OnServerEvent:Connect(function(plr,io)
  43. if plr~=rp then return end
  44. m.Target = io.Target
  45. m.Hit = io.Hit
  46. if not io.isMouse then
  47. local b = io.UserInputState == Enum.UserInputState.Begin
  48. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  49. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  50. end
  51. for _,t in pairs(CAS.Actions) do
  52. for _,k in pairs(t.Keys) do
  53. if k==io.KeyCode then
  54. t.Function(t.Name,io.UserInputState,io)
  55. end
  56. end
  57. end
  58. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  59. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  60. end
  61. end)
  62. Event.Parent = NLS([==[
  63. local Player = game:GetService("Players").LocalPlayer
  64. local Event = script:WaitForChild("UserInput_Event")
  65.  
  66. local Mouse = Player:GetMouse()
  67. local UIS = game:GetService("UserInputService")
  68. local input = function(io,a)
  69. if a then return end
  70. --Since InputObject is a client-side instance, we create and pass table instead
  71. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  72. end
  73. UIS.InputBegan:Connect(input)
  74. UIS.InputEnded:Connect(input)
  75.  
  76. local h,t
  77. --Give the server mouse data 30 times every second, but only if the values changed
  78. --If player is not moving their mouse, client won't fire events
  79. while wait(1/30) do
  80. if h~=Mouse.Hit or t~=Mouse.Target then
  81. h,t=Mouse.Hit,Mouse.Target
  82. Event:FireServer({isMouse=true,Target=t,Hit=h})
  83. end
  84. end]==],Player.Character)
  85.  
  86. ----Sandboxed game object that allows the usage of client-side methods and services
  87. --Real game object
  88. local _rg = game
  89.  
  90. --Metatable for fake service
  91. local fsmt = {
  92. __index = function(self,k)
  93. local s = rawget(self,"_RealService")
  94. if s then return s[k] end
  95. end,
  96. __newindex = function(self,k,v)
  97. local s = rawget(self,"_RealService")
  98. if s then s[k]=v end
  99. end,
  100. __call = function(self,...)
  101. local s = rawget(self,"_RealService")
  102. if s then return s(...) end
  103. end
  104. }
  105. local function FakeService(t,RealService)
  106. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  107. return setmetatable(t,fsmt)
  108. end
  109.  
  110. --Fake game object
  111. local g = {
  112. GetService = function(self,s)
  113. return self[s]
  114. end,
  115. Players = FakeService({
  116. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  117. },"Players"),
  118. UserInputService = FakeService(UIS,"UserInputService"),
  119. ContextActionService = FakeService(CAS,"ContextActionService"),
  120. }
  121. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  122. g.service = g.GetService
  123.  
  124. g.RunService = FakeService({
  125. RenderStepped = _rg:GetService("RunService").Heartbeat,
  126. BindToRenderStep = function(self,name,_,fun)
  127. self._btrs[name] = self.Heartbeat:Connect(fun)
  128. end,
  129. UnbindFromRenderStep = function(self,name)
  130. self._btrs[name]:Disconnect()
  131. end,
  132. },"RunService")
  133.  
  134. setmetatable(g,{
  135. __index=function(self,s)
  136. return _rg:GetService(s) or typeof(_rg[s])=="function"
  137. and function(_,...)return _rg[s](_rg,...)end or _rg[s]
  138. end,
  139. __newindex = fsmt.__newindex,
  140. __call = fsmt.__call
  141. })
  142. --Changing owner to fake player object to support owner:GetMouse()
  143. game,owner = g,g.Players.LocalPlayer
  144. end
  145.  
  146. plr = game.Players.LocalPlayer
  147. mouse = plr:GetMouse()
  148. part = nil
  149. bp = nil
  150. particles = nil
  151. function clerp(a,b,c,d)
  152. for i = 0,d,.01 do
  153. a.CFrame = CFrame.new(b:lerp(c,i))
  154. wait()
  155. end
  156. end
  157. function slerp(a2,b2,c2,d2)
  158. for i2 = 0,d2,.01 do
  159. a2.CFrame = CFrame.new(b2:lerp(c2,i2))
  160. wait()
  161. end
  162. end
  163. mouse.KeyDown:connect(function(key)
  164. if key == "e" and plr.Character.Parent == workspace then
  165. plr.Character.Parent = workspace.Camera
  166. plr.Character.Archivable = true
  167. Instance.new("ForceField",plr.Character).Visible = false
  168. for y,t in pairs(plr.Character:GetChildren()) do
  169. if t:IsA("Part") and t.Name ~= "HumanoidRootPart" then
  170. t.Transparency = 1
  171. if t.Name == "Head" and t:FindFirstChild("face") then
  172. t.face.Transparency = 1
  173. end
  174. elseif t:IsA("Accessory") and t:FindFirstChild("Handle") then
  175. t.Handle.Transparency = 1
  176. end
  177. end
  178. elseif key == "z" and plr.Character.Parent == workspace.Camera and part == nil then
  179. plr.Character.Torso.CFrame = CFrame.new(Vector3.new(mouse.hit.p.X,mouse.hit.p.Y+1.5,mouse.hit.p.Z),plr.Character.Torso.CFrame.p)
  180. elseif key == "x" and plr.Character.Parent == workspace.Camera and part == nil then
  181. if plr.Character.Torso.Anchored == true then
  182. for y,t in pairs(plr.Character:GetChildren()) do
  183. if t:IsA("Part") then
  184. t.Anchored = false
  185. end
  186. end
  187. else
  188. for y,t in pairs(plr.Character:GetChildren()) do
  189. if t:IsA("Part") then
  190. t.Anchored = true
  191. end
  192. end
  193. end
  194. elseif key == "c" and plr.Character.Parent == workspace.Camera and part ~= nil then
  195. local clone = part:Clone()
  196. clone.Parent = workspace
  197. clone.Anchored = false
  198. clone:ClearAllChildren()
  199. clone.CanCollide = true
  200. bp.Parent = clone
  201. particles.Parent = clone
  202. if part.Parent:FindFirstChildOfClass("Humanoid") then
  203. part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false
  204. end
  205. part:Destroy()
  206. part = clone
  207. elseif key == "t" and plr.Character.Parent == workspace.Camera and part == nil then
  208. plr.Character.Parent = workspace
  209. plr.Character.Archivable = false
  210. plr.Character:FindFirstChildOfClass("ForceField"):Remove()
  211. for y,t in pairs(plr.Character:GetChildren()) do
  212. if t:IsA("Part") and t.Name ~= "HumanoidRootPart" then
  213. t.Transparency = 0
  214. if t.Name == "Head" and t:FindFirstChild("face") then
  215. t.face.Transparency = 0
  216. end
  217. elseif t:IsA("Accessory") and t:FindFirstChild("Handle") then
  218. t.Handle.Transparency = 0
  219. end
  220. end
  221. end
  222. end)
  223. mouse.Button1Down:connect(function()
  224. if plr.Character.Parent == workspace.Camera then
  225. if mouse ~= nil then
  226. if mouse.Target ~= nil then
  227. part = mouse.Target
  228. bp = Instance.new("BodyPosition",part)
  229. bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  230. bp.Position = part.Position
  231. particles = Instance.new("ParticleEmitter",part)
  232. particles.Color = ColorSequence.new(Color3.new(0,0,0))
  233. particles.Size = NumberSequence.new(1)
  234. particles.Texture = "rbxassetid://292289455"
  235. particles.VelocitySpread = 360
  236. particles.Speed = NumberRange.new(0)
  237. particles.RotSpeed = NumberRange.new(0)
  238. particles.Rotation = NumberRange.new(0)
  239. particles.Rate = 250
  240. particles.Lifetime = NumberRange.new(.2,.4)
  241. particles.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0,1,0),NumberSequenceKeypoint.new(.12,.688,0),NumberSequenceKeypoint.new(.891,.887,0),NumberSequenceKeypoint.new(1,1,0)})
  242. dwn = true
  243. end
  244. end
  245. while dwn == true do
  246. wait()
  247. bp.Position = mouse.hit.p
  248. if part then
  249. if part.Parent:FindFirstChildOfClass("Humanoid") then
  250. part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = true
  251. end
  252. end
  253. end
  254. end
  255. end)
  256. mouse.Button1Up:connect(function()
  257. dwn = false
  258. if part then if part.Parent:FindFirstChildOfClass("Humanoid") then part.Parent:FindFirstChildOfClass("Humanoid").PlatformStand = false end part = nil end
  259. if bp then bp:Destroy() end
  260. if particles then particles:Destroy() end
  261. end)
  262. base = Instance.new("ScreenGui",plr.PlayerGui)
  263. bbg = Instance.new("BillboardGui",plr.Character.Head)
  264. bbg.Size = UDim2.new(0,200,0,50)
  265. bbg.StudsOffset = Vector3.new(0,3,0)
  266. bbgTl = Instance.new("TextLabel",bbg)
  267. bbgTl.BackgroundTransparency = 1
  268. bbgTl.Size = UDim2.new(10,0,1,0)
  269. bbgTl.Position = UDim2.new(-4.5,0,0,0)
  270. bbgTl.Font = "Code"
  271. bbgTl.Text = " "
  272. bbgTl.TextSize = 25
  273. bbgTl.TextStrokeColor3 = Color3.new(1,1,1)
  274. bbgTl.TextColor3 = Color3.new(0,0,0)
  275. bbgTl.TextStrokeTransparency = 0
  276. bbgTl.TextWrapped = true
  277. plr.Chatted:connect(function(msg)
  278. bbgTl.Text = msg
  279. wait(5)
  280. if bbgTl.Text == msg then
  281. bbgTl.Text = " "
  282. end
  283. end)
  284. touchCounter = 0
  285. while wait() do
  286. if plr.Character.Parent == workspace.Camera then
  287. local c = plr.Character:Clone()
  288. c:MakeJoints()
  289. for y,t in pairs(c:GetChildren()) do
  290. if t:IsA("Part") then
  291. t.CanCollide = false
  292. t.Anchored = true
  293. t.Transparency = .5
  294. t.TopSurface = "Smooth"
  295. t.BottomSurface = "Smooth"
  296. t.RightSurface = "Smooth"
  297. t.LeftSurface = "Smooth"
  298. t.FrontSurface = "Smooth"
  299. t.BackSurface = "Smooth"
  300. t.BrickColor = BrickColor.new("Really black")
  301. if t.Name == "Head" and t:FindFirstChild("face") then
  302. t.face:Remove()
  303. elseif t.Name == "Torso" and t:FindFirstChild("roblox") then
  304. t.roblox:Remove()
  305. elseif t.Name == "HumanoidRootPart" then
  306. t:Remove()
  307. end
  308. else
  309. t:Remove()
  310. end
  311. end
  312. c.Parent = workspace
  313. game.Debris:AddItem(c,.05)
  314. end
  315. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement