Advertisement
Previized

Arena LocalScript

Jan 22nd, 2021 (edited)
11,213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. --// Place this localscript in StarterPlayer > StarterCharacterScripts
  2. --(line 8 is the only line that can be changed unless you know what your doing)
  3.  
  4. local Player = game.Players.LocalPlayer
  5. local Character = Player.Character or Player.CharacterAdded:Wait()
  6. local Humanoid = Character.Humanoid
  7.  
  8. local WEAPON = game.ReplicatedStorage['LinkedSword'] -- Change this to the name of your weapon that is placed in ReplicatedStorage
  9.  
  10. local RS = game:GetService('ReplicatedStorage')
  11. local RemoteEvent = RS:WaitForChild('ToolEvent')
  12.  
  13. local Areas = workspace.Areas
  14. local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
  15.  
  16. local GotSword = false
  17.  
  18. TOUCHING = nil
  19. HumanoidRootPart.Touched:Connect(function(newPart)
  20.     if newPart:IsDescendantOf(Areas) and newPart.Name == 'Main' and TOUCHING == nil then
  21.         TOUCHING = newPart
  22.         if GotSword == false then
  23.             local item = RS:WaitForChild(WEAPON.Name)
  24.             if item then
  25.                 RemoteEvent:FireServer('steppedOn',item)
  26.             end
  27.             GotSword = true
  28.         end
  29.     end
  30. end)
  31.  
  32. HumanoidRootPart.TouchEnded:Connect(function(newPart)
  33.     for _, part in pairs(HumanoidRootPart:GetTouchingParts()) do
  34.         if part == TOUCHING and newPart.Name == 'Main' then return end
  35.     end
  36.     local item = Character:FindFirstChild(WEAPON.Name)
  37.     local item2 = Player.Backpack:FindFirstChild(WEAPON.Name)
  38.     if item or item2 then
  39.         RemoteEvent:FireServer('steppedOff',item or item2)
  40.     end
  41.     TOUCHING = nil
  42.     GotSword = false
  43. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement