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

Why is there Touch interest in the second brick?

Why does part 1 have touch interest but not part 2 I'm really confused?

local sound1 = game.ServerStorage.Sound1
local sound2 = game.ServerStorage.Sound2
local p1 = script.Parent.Part1
local p2 = script.Parent.Part2
local a = sound1:Clone()
debounce = false

p1.Touched:connect(function(part)

if p1.Parent and game.Players:playerFromCharacter(part.Parent) then

local player = game.Players:playerFromCharacter(part.Parent)

if debounce == true then
	if player.Character.Head:findFirstChild("Sound2") then 
		player.Character.Head.Sound2:Destroy()
		else
	end	
	
	elseif debounce == false then      
   
 local a = sound1:Clone()
	a.Parent = player.Character.Head
	a:Play()
    debounce = true
end

p2.Touched:connect(function(part)

if p2.Parent and game.Players:playerFromCharacter(part.Parent) then

local player = game.Players:playerFromCharacter(part.Parent)

if debounce == true then
	if player.Character.Head:findFirstChild("Sound2") then 
		player.Character.Head.Sound2:Destroy()
		else
	end	
	
	elseif debounce == false then      
   
 local a = sound2:Clone()
	a.Parent = player.Character.Head
	a:Play()
    debounce = true
end
end
end)
end
end)

2 comments

0

use GetPlayerFromCharacter instead of playerFromCharacter. I believe that should fix it.

0

That's completely irrelevant, actually, although playerFromCharacter is deprecated.

1 answer

TouchInterests are used by the ROBLOX engine internally for Touched events.

Does your code work fully as expected?

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