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

How do I detect the speed and then the collision?

Asked by 4 years ago

I am trying to play a sound whenever the bumper collides on something, but it doesn't seem to play when the car hits something when driving at a specific speed.

local part = script.Parent
local seat = script.Parent.Parent.Parent.DriveSeat
local s = script.Parent.Parent.Parent.DriveSeat.Hit

if seat.Throttle >= 10 then
    local function onPartTouched(otherPart)
        print(part.Name .. " has touched " .. otherPart.Name)
        s:Play()
    end
    part.Touched:Connect(onPartTouched)
end
0
Is anything being printed? Soban06 410 — 4y
0
No Gam3r_Play3r 47 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

I think you need to switch it around. Maybe this will work?

local part = script.Parent
local seat = script.Parent.Parent.Parent.DriveSeat
local s = script.Parent.Parent.Parent.DriveSeat.Hit


local function onPartTouched(otherPart)
        if seat.Throttle == 1 then
        print(part.Name .. " has touched " .. otherPart.Name)
        s:Play()
        end
end

part.Touched:Connect(onPartTouched)
Ad

Answer this question