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

Why is there no touch interest in part 2?

Asked by
Nidoxs 190
9 years ago

Part 1 has touch interest but part 2 doesn't. I'm 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)

Answer this question