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

.TouchedEvent FIRING at a wrong time?

If i put a part against it it welds but the music doesnt play

local soundbase = script.Parent.Parent.RadioBase
local removedpos = script.Parent.ABC
local debounce = false
function weld(hit)
	local weld = Instance.new("WeldConstraint")
	weld.Name =  "Weldd"
	weld.Parent = script.Parent
	weld.Part0 = script.Parent
	weld.Part1 = hit
end

local sounds = {
	"forever",
	"shadow"
	
}

script.Parent.Touched:Connect(function(hit) 
	if not debounce  then
		debounce = true
	for value,name in ipairs(sounds) do
			if hit.Name == name then
				ON = true
			soundbase:FindFirstChild(name):Play()
			hit.CFrame = script.Parent.CFrame
			weld(hit)
			--	soundbase:FindFirstChild(name):Play()
				print("done")
				wait(3)
				debounce = false
		end
		end
		end
	
end)
	


script.Parent.TouchEnded:Connect(function(hit)
	for value,name in ipairs(sounds) do
		if hit.Name == name then
			soundbase:FindFirstChild(name):Pause(true)
			hit.CFrame =  removedpos.CFrame
			--script.Parent.Weldd.Part1 = nil
		end
	end
end)


7 comments

0

I MEANT TOUCHENDE

0

r u saying that when you touch a certain part it has to make sound? but it isnt ?

0

r u saying that when you touch a certain part it has to make sound? but it isnt ?

0

r u saying that when you touch a certain part it has to make sound? but it isnt ?

0

yes

0

so its like when i put a part against it it plays a sound if i remove it put it back it doesnt play

0

i answered your question

1 answer

make sure in the explorer, that the sound you got is in the model. then it should work

2 comments

0

THE TOUCHED EVENT AND TOUCHENDED EVENT FIRE AT THE SAME TIME

0

yeah.

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