Advertisement
matssss2387234823

YtScriptS

Mar 29th, 2019
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. toolHandler script:
  2.  
  3. local re = Instance.new("RemoteEvent")
  4. re.Parent = game:GetService("ReplicatedStorage")
  5. re.Name = "toolEvent"
  6.  
  7. re.OnServerEvent:Connect(function(plr, tool)
  8. local mag = (tool:WaitForChild("Handle").Position - plr.Character.HumanoidRootPart.Position).magnitude
  9.  
  10. if mag < 5 then
  11. tool.Parent = plr.Backpack
  12. end
  13. end)
  14.  
  15. function untouch(list)
  16. for i = 1, #list do
  17. local handle = list[i]:WaitForChild("Handle")
  18. if handle then
  19. local ti = handle:FindFirstChild("antiTouch") -- <
  20. if not ti then
  21. local clone = script.antiTouch:Clone() -- <
  22. clone.Parent = handle
  23. clone.Disabled = false
  24. end
  25. end
  26. end
  27. end
  28.  
  29. local tools = workspace:WaitForChild("tools"):GetChildren()
  30. untouch(tools)
  31.  
  32. workspace.tools.ChildAdded:Connect(function(child)
  33. untouch({child})
  34. end)
  35.  
  36. workspace.ChildAdded:Connect(function(child)
  37. if child:IsA("Tool") then
  38. wait()
  39. child.Parent = workspace.tools
  40. end
  41. end)
  42.  
  43.  
  44.  
  45.  
  46. antiTouch Script:
  47.  
  48. local ti = script.Parent:FindFirstChild("TouchInterest")
  49. if ti then
  50. ti:Destroy()
  51. end
  52.  
  53. script.Parent.ChildAdded:Connect(function(child)
  54. if child:IsA("TouchTransmitter") then
  55. wait()
  56. child:Destroy()
  57. end
  58. end)
  59.  
  60. toolScript:
  61.  
  62.  
  63. local uis = game:GetService("UserInputService")
  64. local rs = game:GetService("ReplicatedStorage")
  65. local event = rs:WaitForChild("toolEvent") -- <
  66.  
  67. local plr = game.Players.LocalPlayer
  68. local kg = plr.PlayerGui:WaitForChild("keyGui")
  69. local char = plr.Character
  70.  
  71. function search()
  72. local tools = workspace:WaitForChild("tools"):GetChildren()
  73. local min = nil
  74. local tool = nil
  75.  
  76. for i = 1, #tools do
  77. local handle = tools[i]:FindFirstChild("Handle")
  78. if handle then
  79. local mag = (char.HumanoidRootPart.Position-handle.Position).magnitude
  80. if min == nil or mag < min then
  81. min = mag
  82. tool = tools[i]
  83. end
  84. end
  85. end
  86.  
  87. if min then
  88. if min < 5 then
  89. return tool
  90. end
  91. end
  92. end
  93.  
  94. uis.InputBegan:Connect(function(input, gameProcessed)
  95. if input.UserInputType.Name == "Keyboard" and gameProcessed == false then
  96. if input.KeyCode.Name == "E" then
  97. local tool = search()
  98. if tool then
  99. event:FireServer(tool)
  100. kg.E.Visible = false
  101. end
  102. end
  103. end
  104. end)
  105.  
  106. while wait(1) do
  107. local tool = search()
  108. if tool then
  109. kg.E.Visible = true
  110. else
  111. kg.E.Visible = false
  112. end
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement