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

Sup, I have a problem... Mind helping me out?

Asked by 1 year ago

I wanted to make that when an object aka: Ball touches an specific part, then it will play the sound. But not when the player touches the Part but only the part.

local part = script.Parent


part.Touched:Connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
        local sound = script.Parent.Sound

        if not sound.IsPlaying then
            sound:Play()
        end
    end
end)
0
In the future, please include the specific question you have in the question title. ScriptGuider 5640 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

If you want it to be a specific object you could try

script.Parent.Touched:Connect(function(part)
    if part.Name = "SpecificPartIWant" then
        local sound = script.Parent.Sound

        if not sound.IsPlaying then
            sound:Play()
        end
    end
end)
0
Thank! It worked but you forgot to add another "=" by if part.Name = "SpecificPartIWant" then it should be if part.Name == "SpecificPartIWant" then GameGuy300K 4 — 1y
Ad

Answer this question