Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// Place this localscript in StarterPlayer > StarterCharacterScripts
- --(line 8 is the only line that can be changed unless you know what your doing)
- local Player = game.Players.LocalPlayer
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local Humanoid = Character.Humanoid
- local WEAPON = game.ReplicatedStorage['LinkedSword'] -- Change this to the name of your weapon that is placed in ReplicatedStorage
- local RS = game:GetService('ReplicatedStorage')
- local RemoteEvent = RS:WaitForChild('ToolEvent')
- local Areas = workspace.Areas
- local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
- local GotSword = false
- TOUCHING = nil
- HumanoidRootPart.Touched:Connect(function(newPart)
- if newPart:IsDescendantOf(Areas) and newPart.Name == 'Main' and TOUCHING == nil then
- TOUCHING = newPart
- if GotSword == false then
- local item = RS:WaitForChild(WEAPON.Name)
- if item then
- RemoteEvent:FireServer('steppedOn',item)
- end
- GotSword = true
- end
- end
- end)
- HumanoidRootPart.TouchEnded:Connect(function(newPart)
- for _, part in pairs(HumanoidRootPart:GetTouchingParts()) do
- if part == TOUCHING and newPart.Name == 'Main' then return end
- end
- local item = Character:FindFirstChild(WEAPON.Name)
- local item2 = Player.Backpack:FindFirstChild(WEAPON.Name)
- if item or item2 then
- RemoteEvent:FireServer('steppedOff',item or item2)
- end
- TOUCHING = nil
- GotSword = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement