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

Why is there Touch interest in the second brick?

Asked by
Nidoxs 190
9 years ago

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)
0
use GetPlayerFromCharacter instead of playerFromCharacter. I believe that should fix it. aquathorn321 858 — 9y
0
That's completely irrelevant, actually, although `playerFromCharacter` *is* deprecated. adark 5487 — 9y

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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

Does your code work fully as expected?

Ad

Answer this question