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

How come my music playing Touched script isn't working?

Asked by 8 years ago

For some reason, whenever I run my script, nothing shows up in the output or the dev console. I wanted to make my script run when a player from a specific team touches a brick. If I remove the lines relating to "player", the script works fine, but without team detecting capabilities.

debounce = false

function onTouched(hit)

    local player = game.Players:GetPlayerFromCharacter(hit.Parent)

    if player then

        if player.TeamColor == ("Bright red") then

            if debounce == false then

    debounce = true

    script.Parent.Alert:play()
    wait(1)
    script.Parent.CaughtMusic:play()
    wait(60)
    script.Parent.CaughtMusic:Stop()

    debounce = false    
            else
                print("k m8 you are a cop, ill let u free")

end 
end     
end

script.Parent.Touched:connect(onTouched)


2 answers

Log in to vote
1
Answered by 8 years ago

If I am correct, your error is on line 9. TeamColor is a BrickColor value, meaning you have to use BrickColor.new("Bright red"), not just ("Bright red").

I hope I was right, haha! Good luck.

Ad
Log in to vote
-1
Answered by 8 years ago

"Bright Red" Isn't a team color its a BrickColor

Answer this question