Advertisement
InTesting

Clothing Cloner

Jan 13th, 2019
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.19 KB | None | 0 0
  1. -- Instructions:
  2. --[[
  3. Any local variables with :
  4.  = LocalPlayer:
  5.     Must be replaced with "owner". So if your local variable is game.Players.LocalPlayer , replace it with owner
  6.  = :GetMouse():
  7.     Remove the variable entirely.
  8.  
  9. then paste this over the desired script
  10. --]]
  11.  
  12. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  13. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  14. do
  15.     print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  16.     script.Parent = Player.Character
  17.  
  18.     --RemoteEvent for communicating
  19.     local Event = Instance.new("RemoteEvent")
  20.     Event.Name = "UserInput_Event"
  21.     --Fake event to make stuff like Mouse.KeyDown work
  22.     local function fakeEvent()
  23.         local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  24.         t.connect = t.Connect
  25.         return t
  26.     end
  27.     --Creating fake input objects with fake variables
  28.     local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  29.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  30.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  31.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  32.     end}
  33.     --Merged 2 functions into one by checking amount of arguments
  34.     CAS.UnbindAction = CAS.BindAction
  35.  
  36.     --This function will trigger the events that have been :Connect()'ed
  37.     local function te(self,ev,...)
  38.         local t = m[ev]
  39.         if t and t._fakeEvent and t.Function then
  40.             t.Function(...)
  41.         end
  42.     end
  43.     m.TrigEvent = te
  44.     UIS.TrigEvent = te
  45.     Event.OnServerEvent:Connect(function(plr,io)
  46.         if plr~=Player then return end
  47.         if io.isMouse then
  48.             m.Target = io.Target
  49.             m.Hit = io.Hit
  50.         else
  51.             local b = io.UserInputState == Enum.UserInputState.Begin
  52.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  53.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  54.             end
  55.             for _,t in pairs(CAS.Actions) do
  56.                 for _,k in pairs(t.Keys) do
  57.                     if k==io.KeyCode then
  58.                         t.Function(t.Name,io.UserInputState,io)
  59.                     end
  60.                 end
  61.             end
  62.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  63.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  64.         end
  65.     end)
  66.     Event.Parent = NLS([==[
  67.     local Player = game:GetService("Players").LocalPlayer
  68.     local Event = script:WaitForChild("UserInput_Event")
  69.     local UIS = game:GetService("UserInputService")
  70.     local input = function(io,a)
  71.         if a then return end
  72.         --Since InputObject is a client-side instance, we create and pass table instead
  73.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  74.     end
  75.     UIS.InputBegan:Connect(input)
  76.     UIS.InputEnded:Connect(input)
  77.     local Mouse = Player:GetMouse()
  78.     local h,t
  79.     --Give the server mouse data 30 times every second, but only if the values changed
  80.     --If player is not moving their mouse, client won't fire events
  81.     while wait(1/30) do
  82.         if h~=Mouse.Hit or t~=Mouse.Target then
  83.             h,t=Mouse.Hit,Mouse.Target
  84.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  85.         end
  86.     end]==],Player.Character)
  87.     Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  88. end
  89. -- End of FE converter
  90. local char = owner.Character
  91. mouse.KeyDown:Connect(function(key)
  92.     if key=="q" then
  93.         if char:FindFirstChildWhichIsA("Shirt") then
  94.             if mouse.Target.Parent:FindFirstChildWhichIsA("Shirt") then
  95.                 char:FindFirstChildWhichIsA("Shirt").ShirtTemplate = mouse.Target.Parent:FindFirstChildWhichIsA("Shirt").ShirtTemplate
  96.                 print("Got "..mouse.Target.Parent.Name.."'s Shirt. AssetID = "..mouse.Target.Parent:FindFirstChildWhichIsA("Shirt").ShirtTemplate)
  97.             elseif mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Shirt") then
  98.                 char:FindFirstChildWhichIsA("Shirt").ShirtTemplate = mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Shirt").ShirtTemplate
  99.                 print("Got "..mouse.Target.Parent.Parent.Name.."'s Shirt. AssetID = "..mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Shirt").ShirtTemplate)
  100.             else
  101.                 print("Either the mouse pointed at a non-player,")
  102.                 print("or the mouse pointed at a player with no")
  103.                 print("shirt.")
  104.             end
  105.         else
  106.             if mouse.Target.Parent:FindFirstChildWhichIsA("Shirt") then
  107.                 print("You have no shirt, making you a shirt.")
  108.                 print("Got "..mouse.Target.Parent.Name.."'s Shirt. AssetID = "..mouse.Target.Parent:FindFirstChildWhichIsA("Shirt").ShirtTemplate)
  109.                 local Cshirt = mouse.Target.Parent:FindFirstChildWhichIsA("Shirt"):Clone()
  110.                 Cshirt.Parent = char
  111.             elseif mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Shirt") then
  112.                 local Cshirt = mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Shirt"):Clone()
  113.                 Cshirt.Parent = char
  114.                 print("Got "..mouse.Target.Parent.Parent.Name.."'s Shirt. AssetID = "..mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Shirt").ShirtTemplate)
  115.             else
  116.                 print("Either the mouse pointed at a non-player,")
  117.                 print("or the mouse pointed at a player with no")
  118.                 print("shirt.")
  119.             end
  120.         end
  121.     elseif key=="e" then
  122.         if char:FindFirstChildWhichIsA("Pants") then
  123.             if mouse.Target.Parent:FindFirstChildWhichIsA("Pants") then
  124.                 char:FindFirstChildWhichIsA("Pants").PantsTemplate = mouse.Target.Parent:FindFirstChildWhichIsA("Pants").PantsTemplate
  125.                 print("Got "..mouse.Target.Parent.Name.."'s Pants. AssetID = "..mouse.Target.Parent:FindFirstChildWhichIsA("Pants").PantsTemplate)
  126.             elseif mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Pants") then
  127.                 char:FindFirstChildWhichIsA("Pants").PantsTemplate = mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Pants").PantsTemplate
  128.                 print("Got "..mouse.Target.Parent.Parent.Name.."'s Pants. AssetID = "..mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Pants").PantsTemplate)
  129.             else
  130.                 print("Either the mouse pointed at a non-player,")
  131.                 print("or the mouse pointed at a player with no")
  132.                 print("pants.")
  133.             end
  134.         else
  135.             if mouse.Target.Parent:FindFirstChildWhichIsA("Shirt") then
  136.                 print("You have no pants, making you pants.")
  137.                 print("Got "..mouse.Target.Parent.Name.."'s Pants. AssetID = "..mouse.Target.Parent:FindFirstChildWhichIsA("Pants").PantsTemplate)
  138.                 local Cshirt = mouse.Target.Parent:FindFirstChildWhichIsA("Pants"):Clone()
  139.                 Cshirt.Parent = char
  140.             elseif mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Pants") then
  141.                 local Cshirt = mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Pants"):Clone()
  142.                 Cshirt.Parent = char
  143.                 print("Got "..mouse.Target.Parent.Parent.Name.."'s Pants. AssetID = "..mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Pants").PantsTemplate)
  144.             else
  145.                 print("Either the mouse pointed at a non-player,")
  146.                 print("or the mouse pointed at a player with no")
  147.                 print("pants.")
  148.             end
  149.            
  150.         end
  151.     end
  152. end)
  153. print("Loaded Clothing Cloner:")
  154. print("Q for shirts.")
  155. print("E for pants.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement