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

I need a part that cancollide = true if it's under 50 speed, and cancollide = false if it's over?

Asked by
cc0de 35
8 years ago

Basically it's designed for a vehicle, if the vehicle is going over 50 SPS, the part detects it and cancollide = false, and back to cancollide = true if it's under. Except this doesn't happen. What have I done wrong?

P = script.Parent
Player = game.Players.LocalPlayer
Human = Player.Character
Torso = Human.Torso


while true do
    wait(.05)
    local intSpeed = math.floor((Torso.Velocity.magnitude)/1.6)
    if Torso.Velocity >= 50  then P.CanCollide = false end
    if Torso.Velocity <= 50 then P.CanCollide = true end
end

1 answer

Log in to vote
0
Answered by 8 years ago

Magnitude
It was hiding just under your nose

P = script.Parent
Player = game.Players.LocalPlayer
Human = Player.Character
Torso = Human.Torso


while true do
    wait(.05)
    local intSpeed = math.floor((Torso.Velocity.magnitude)/1.6)
    if intSpeed >= 50  then P.CanCollide = false end
    if intSpeed <= 50 then P.CanCollide = true end
end

If it wasn't intSpeed that you needed, or you're a little confused about the dampening going on (why it only works at 80 instead of 50), you might want to get rid of that little division up there.

0
It still doesn't work. When in a vehicle, and travelling at 50, this SHOULD make a part's cancollide property change. I used transparency instead to test it easier., but it still doesn't. cc0de 35 — 8y
0
Do you know if the Torso's Velocity does actually change when in a car? PlsNoDiscrimination 0 — 8y
0
I believe so. I got the velocity part from a speed tracking script that does work. cc0de 35 — 8y
Ad

Answer this question