Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I detect the speed and then the collision?

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

2 comments

0

Is anything being printed?

0

No

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.