#i need help with a push script

17 messages · Page 1 of 1 (latest)

proud burrow
#

so basically i made a script which pushes people and i cant figure out why it only pushes the person in one direction

#

script.Parent.Push.OnServerEvent:Connect(function(player, toPush)

    if db then return end
    db = true
    task.delay(15, function() db = false end)

    local playerRoot = player.Character:FindFirstChild("HumanoidRootPart")
    local pushRoot = toPush:FindFirstChild("HumanoidRootPart")

    if playerRoot and not playerRoot:FindFirstChild("PushF") and pushRoot and not pushRoot:FindFirstChild("PushF") then

        if (playerRoot.Position - pushRoot.Position).Magnitude > 6 then return end

        local pushF = Instance.new("BodyVelocity")
        pushF.Name = "PushF"
        pushF.MaxForce = Vector3.new(100000, 100000, 100000)
        pushF.Velocity = (-pushRoot.CFrame.lookVector) * 50

        pushF.Parent = pushRoot

        wait(0.3)
        pushF:Destroy()
    end
end)```
tacit crater
#
local db = false

script.Parent.Push.OnServerEvent:Connect(function(player, toPush)

    if db then return end
    db = true
    task.delay(15, function() db = false end)

    local playerRoot = player.Character:FindFirstChild("HumanoidRootPart")
    local pushRoot = toPush:FindFirstChild("HumanoidRootPart")

    if playerRoot and not playerRoot:FindFirstChild("PushF") and pushRoot and not pushRoot:FindFirstChild("PushF") then

        if (playerRoot.Position - pushRoot.Position).Magnitude > 6 then return end

        local pushF = Instance.new("BodyVelocity")
        pushF.Name = "PushF"
        pushF.MaxForce = Vector3.new(100000, 100000, 100000)
        pushF.Velocity = (playerRoot.CFrame.lookVector) * 50  --playerRoot instead of -PushRoot

        pushF.Parent = pushRoot

        wait(0.3)
        pushF:Destroy()
    end
end)
proud burrow
#

the whole script dosen't work anymore

tacit crater
#

Output

proud burrow
#

it dosen't appear in the output

#

nvm

#

ty

#

robbe i got another little problem

#

@tacit crater

tacit crater
#

...

proud burrow
#

the push script dosen't work again after the first push

tacit crater
#

you put in a delay of 15 Sekonds

proud burrow
#

that wasn't changeable?

tacit crater
#

you can change it, but then you can only punch every 15 sec

proud burrow
#

yeah

#

but even if i wait 15 secs