Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I created a hammer tool and it should know people back however it only works one way?

Asked by 5 years ago

I created a hammer and whenever you hit someone it should launch them in the direction you were facing however it works for me but not if anyone tries to hit me...

ServerScript

local event = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("FlingHandler")



event.OnServerEvent:Connect(function(Player,hit)
    local Force = Instance.new("BodyForce")
    local Look = Player.Character.HumanoidRootPart.CFrame.LookVector
    Force.Force = Look*12000
    Force.Parent = hit.Parent.HumanoidRootPart
    wait(.25)
    Force:Destroy()
end)

ToolScript

local Tool = script.Parent
local Attack = script:WaitForChild("HitAnim")
Player = Tool.Parent.Parent
local Attacking = false
local Cooldown = false
Tool.Activated:Connect(function()
    if not Cooldown then
        Cooldown = true
        Attacking = true
        game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("AnimationHandler"):FireServer(Attack,'NIL')
        wait(1)
        Attacking = false
        Cooldown = false
    end
end)

Tool.Handle.Touched:Connect(function(hit)
    if Attacking and hit.Parent:FindFirstChild("Humanoid") and Player.Team.Name ~= 'Spectator'  then
        game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("FlingHandler"):FireServer(hit)
        Attacking = false
    elseif Attacking and hit.Name == 'BlueJewel' and Player.Team.Name == 'Orange' then
        game.ReplicatedStorage:WaitForChild('Remotes'):WaitForChild("BaseDamageHandler"):FireServer('BlueJewel')
        Attacking = false
    elseif Attacking and hit.Name == 'OrangeJewel' and Player.Team.Name == 'Blue' then
        game.ReplicatedStorage:WaitForChild('Remotes'):WaitForChild("BaseDamageHandler"):FireServer('OrangeJewel')
        Attacking = false
    end
    wait(.5)
end)


Answer this question