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

.TouchedEvent FIRING at a wrong time?

Asked by 2 years ago

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)


0
I MEANT TOUCHENDE Mel_pro1 5 — 2y
0
r u saying that when you touch a certain part it has to make sound? but it isnt ? extrorobo 104 — 2y
0
r u saying that when you touch a certain part it has to make sound? but it isnt ? extrorobo 104 — 2y
0
r u saying that when you touch a certain part it has to make sound? but it isnt ? extrorobo 104 — 2y
View all comments (3 more)
0
yes Mel_pro1 5 — 2y
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 Mel_pro1 5 — 2y
0
i answered your question extrorobo 104 — 2y

1 answer

Log in to vote
0
Answered by
extrorobo 104
2 years ago

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

0
THE TOUCHED EVENT AND TOUCHENDED EVENT FIRE AT THE SAME TIME Mel_pro1 5 — 2y
0
yeah. extrorobo 104 — 2y
Ad

Answer this question