Advertisement
HenloMyDude

prop hunt

Sep 7th, 2019
702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.11 KB | None | 0 0
  1.  
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do
  6. print("FE Compatibility code V2 by Mokiros")
  7. local RealPlayer = RealPlayer
  8. script.Parent = RealPlayer.Character
  9.  
  10. --Fake event to make stuff like Mouse.KeyDown work
  11. local Disconnect_Function = function(this)
  12. this[1].Functions[this[2]] = nil
  13. end
  14. local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  15. local FakeEvent_Metatable = {__index={
  16. Connect = function(this,f)
  17. local i = tostring(math.random(0,10000))
  18. while this.Functions[i] do
  19. i = tostring(math.random(0,10000))
  20. end
  21. this.Functions[i] = f
  22. return setmetatable({this,i},Disconnect_Metatable)
  23. end
  24. }}
  25. FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  26. local function fakeEvent()
  27. return setmetatable({Functions={}},FakeEvent_Metatable)
  28. end
  29.  
  30. --Creating fake input objects with fake variables
  31. local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  32. FakeMouse.keyUp = FakeMouse.KeyUp
  33. FakeMouse.keyDown = FakeMouse.KeyDown
  34. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  35. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  36. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  37. end}
  38. --Merged 2 functions into one by checking amount of arguments
  39. CAS.UnbindAction = CAS.BindAction
  40.  
  41. --This function will trigger the events that have been :Connect()'ed
  42. local function TriggerEvent(self,ev,...)
  43. for _,f in pairs(self[ev].Functions) do
  44. f(...)
  45. end
  46. end
  47. FakeMouse.TriggerEvent = TriggerEvent
  48. UIS.TriggerEvent = TriggerEvent
  49.  
  50. --Client communication
  51. local Event = Instance.new("RemoteEvent")
  52. Event.Name = "UserInput_Event"
  53. Event.OnServerEvent:Connect(function(plr,io)
  54. if plr~=RealPlayer then return end
  55. FakeMouse.Target = io.Target
  56. FakeMouse.Hit = io.Hit
  57. if not io.isMouse then
  58. local b = io.UserInputState == Enum.UserInputState.Begin
  59. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  60. return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  61. end
  62. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  63. return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  64. end
  65. for _,t in pairs(CAS.Actions) do
  66. for _,k in pairs(t.Keys) do
  67. if k==io.KeyCode then
  68. t.Function(t.Name,io.UserInputState,io)
  69. end
  70. end
  71. end
  72. FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  73. UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  74. end
  75. end)
  76. Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  77. local Mouse = owner:GetMouse()
  78. local UIS = game:GetService("UserInputService")
  79. local input = function(io,RobloxHandled)
  80. if RobloxHandled then return end
  81. --Since InputObject is a client-side instance, we create and pass table instead
  82. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  83. end
  84. UIS.InputBegan:Connect(input)
  85. UIS.InputEnded:Connect(input)
  86. local h,t
  87. --Give the server mouse data every second frame, but only if the values changed
  88. --If player is not moving their mouse, client won't fire events
  89. local HB = game:GetService("RunService").Heartbeat
  90. while true do
  91. if h~=Mouse.Hit or t~=Mouse.Target then
  92. h,t=Mouse.Hit,Mouse.Target
  93. Event:FireServer({isMouse=true,Target=t,Hit=h})
  94. end
  95. --Wait 2 frames
  96. for i=1,2 do
  97. HB:Wait()
  98. end
  99. end]==],script)
  100.  
  101. ----Sandboxed game object that allows the usage of client-side methods and services
  102. --Real game object
  103. local RealGame = game
  104.  
  105. --Metatable for fake service
  106. local FakeService_Metatable = {
  107. __index = function(self,k)
  108. local s = rawget(self,"_RealService")
  109. if s then
  110. return typeof(s[k])=="function"
  111. and function(_,...)return s[k](s,...)end or s[k]
  112. end
  113. end,
  114. __newindex = function(self,k,v)
  115. local s = rawget(self,"_RealService")
  116. if s then s[k]=v end
  117. end
  118. }
  119. local function FakeService(t,RealService)
  120. t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  121. return setmetatable(t,FakeService_Metatable)
  122. end
  123.  
  124. --Fake game object
  125. local FakeGame = {
  126. GetService = function(self,s)
  127. return rawget(self,s) or RealGame:GetService(s)
  128. end,
  129. Players = FakeService({
  130. LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  131. },"Players"),
  132. UserInputService = FakeService(UIS,"UserInputService"),
  133. ContextActionService = FakeService(CAS,"ContextActionService"),
  134. RunService = FakeService({
  135. _btrs = {},
  136. RenderStepped = RealGame:GetService("RunService").Heartbeat,
  137. BindToRenderStep = function(self,name,_,fun)
  138. self._btrs[name] = self.Heartbeat:Connect(fun)
  139. end,
  140. UnbindFromRenderStep = function(self,name)
  141. self._btrs[name]:Disconnect()
  142. end,
  143. },"RunService")
  144. }
  145. rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  146. FakeGame.service = FakeGame.GetService
  147. FakeService(FakeGame,game)
  148. --Changing owner to fake player object to support owner:GetMouse()
  149. game,owner = FakeGame,FakeGame.Players.LocalPlayer
  150. end
  151.  
  152. plr = owner
  153. char = plr.Character
  154. mouse = plr:GetMouse()
  155.  
  156. ezweld = function(p, a, b, cf)
  157. local weld = Instance.new("Weld",p)
  158. weld.Part0 = a
  159. weld.Part1 = b
  160. weld.C0 = cf
  161. return weld
  162. end
  163.  
  164. invis = function(chara)
  165. for _,v in pairs (chara:children()) do
  166. if v:IsA("Hat") or v:IsA("Accessory") then
  167. v:FindFirstChildOfClass("Part").Transparency = 1
  168. end
  169. if v:IsA("Part") or v:IsA("MeshPart") then
  170. v.Transparency = 1
  171. for _,v in pairs (v:children()) do
  172. if v:IsA("Decal") or v:IsA("Texture") then
  173. v.Transparency = 1
  174. end
  175. end
  176. end
  177. if v:IsA("Model") then
  178. for _,v in pairs (chara:children()) do
  179. if v:IsA("Hat") or v:IsA("Accessory") then
  180. v:FindFirstChildOfClass("Part").Transparency = 1
  181. end
  182. if v:IsA("Part") or v:IsA("MeshPart") and v.Name ~= "HumanoidRootPart" then
  183. v.Transparency = 1
  184. for _,v in pairs (v:children()) do
  185. if v:IsA("Decal") or v:IsA("Texture") then
  186. v.Transparency = 1
  187. end
  188. end
  189. end
  190. end
  191. end
  192. end
  193. end
  194.  
  195. uninvis = function(chara)
  196. for _,v in pairs (chara:children()) do
  197. if v:IsA("Hat") or v:IsA("Accessory") then
  198. v:FindFirstChildOfClass("Part").Transparency = 0
  199. end
  200. if v:IsA("Part") or v:IsA("MeshPart") and v.Name ~= "HumanoidRootPart" then
  201. v.Transparency = 0
  202. for _,v in pairs (v:children()) do
  203. if v:IsA("Decal") or v:IsA("Texture") then
  204. v.Transparency = 0
  205. end
  206. end
  207. if v.Name == "HumanoidRootPart" then
  208. v.Transparency = 1
  209. end
  210. end
  211. if v:IsA("Model") then
  212. for _,v in pairs (chara:children()) do
  213. if v:IsA("Hat") or v:IsA("Accessory") then
  214. v:FindFirstChildOfClass("Part").Transparency = 0
  215. end
  216. if v:IsA("Part") or v:IsA("MeshPart") and v.Name ~= "HumanoidRootPart" then
  217. v.Transparency = 0
  218. for _,v in pairs (v:children()) do
  219. if v:IsA("Decal") or v:IsA("Texture") then
  220. v.Transparency = 0
  221. end
  222. end
  223. end
  224. end
  225. end
  226. end
  227. end
  228.  
  229. function removeprops(chara)
  230. for _,v in pairs (chara:children()) do
  231. if v:IsA("Part") or v:IsA("MeshPart") then
  232. if v.Name == "prop" then
  233. v:Destroy()
  234. uninvis(chara)
  235. end
  236. end
  237. if v:IsA("MeshPart") then
  238. if v.Name == "prop" then
  239. v:Destroy()
  240. uninvis(chara)
  241. end
  242. end
  243. if v:IsA("UnionOperation") then
  244. if v.Name == "prop" then
  245. v:Destroy()
  246. uninvis(chara)
  247. end
  248. end
  249. if v:IsA("WedgePart") then
  250. if v.Name == "prop" then
  251. v:Destroy()
  252. uninvis(chara)
  253. end
  254. end
  255. if v:IsA("CornerWedgePart") then
  256. if v.Name == "prop" then
  257. v:Destroy()
  258. uninvis(chara)
  259. end
  260. end
  261. if v:IsA("TrussPart") then
  262. if v.Name == "prop" then
  263. v:Destroy()
  264. uninvis(chara)
  265. end
  266. end
  267. end
  268. end
  269.  
  270. function transform()
  271. if mouse.Target then
  272. removeprops(char)
  273. local part = mouse.Target
  274. invis(char)
  275. local newpart = part:Clone()
  276. newpart.Name = "prop"
  277. newpart.Anchored = false
  278. newpart.Parent = char
  279. newpart:BreakJoints()
  280. local headlerp = ezweld(char.Head, char.Torso, char.Head, CFrame.new())
  281. local weld = ezweld(char, char.HumanoidRootPart, newpart, CFrame.new(0,-3+newpart.Size.Y/2,0))
  282. return newpart
  283. end
  284. end
  285.  
  286. --[[
  287. mouse.Button1Down:connect(function()
  288. if mouse.Target then
  289. removeprops(char)
  290. local part = mouse.Target
  291. invis(char)
  292. local newpart = part:Clone()
  293. newpart.Name = "prop"
  294. newpart.Anchored = false
  295. newpart.Parent = char
  296. ezweld(char, newpart, char.HumanoidRootPart, CFrame.new())
  297. end
  298. end)
  299. ]]--
  300.  
  301. mouse.KeyDown:connect(function(key)
  302. key=key:lower()
  303. if key == "q" then
  304. transform()
  305. end
  306. if key == "e" then
  307. removeprops(char)
  308. uninvis(char)
  309. char.Head:FindFirstChildOfClass("Weld"):Destroy()
  310. end
  311. end)
  312.  
  313. print([[some chat controls:
  314. /offset x,y,z (use cframe coordinates)
  315. do not put spaces between x,y,z
  316. ]])
  317.  
  318. plr.Chatted:connect(function(message)
  319. message = message:lower()
  320. if message:sub(0, 7) == "/offest" then
  321. weld.C0 = CFrame.new(message:sub(9),message:sub(10),message:sub(11))
  322. end
  323. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement