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

When player collides into object at certain speed?

Asked by 6 years ago
Edited 6 years ago

Im making an effect that if the players velocity is over a certain value and then it hits an object then a brick from replicatedstorage gets cloned 5 times to player, to create the effect of the object "breaking". No errors But what happens is that when the player jumps off the ground, the effect get cloned, which is not what's supposed to happen.

local Humanoid = script.Parent.Humanoid
local busy = false
function collided_With_Something(hit)
    if not busy and hit.Parent.Name ~= "broke" then
        busy = true
        if script.Parent.HumanoidRootPart.Velocity.Magnitude > 150 then
                                for i = 1,5 do
                                    print(i)
                    local bro = game.ReplicatedStorage.broke:Clone()
                    bro.Parent = workspace
                    bro.CFrame = script.Parent.HumanoidRootPart.CFrame
                    bro.Color = hit.Color
                                end
          end
        wait(3)
        busy = false
    end
end

Humanoid.Touched:Connect(collided_With_Something)
0
This will run for every part of the humanoid. You need to define what parts should cause the effect, it might be better to use the touched event of the part rather than the humanoid. User#5423 17 — 6y
0
its meant to be the whole player taunter165 30 — 6y

Answer this question