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

Can someone help me fix this script? I want to play a sound when a boolvalue is triggered.

Asked by 3 years ago

I don't have much knowledge to scripting so I need a helping hand. Basically, I want a sound to play once a BoolValue is triggered. Here's an example (Note that the BoolValue works fine and it's named "Chasing" and the sound I want to play is located at game.Workspace.Monster6.HumanoidRootPart.footsteps2)

**script.Parent.Chasing.Changed:Connect(function() if script.Parent.Chasing.Value == true then

local sound = game.Workspace.Monster6.HumanoidRootPart.footsteps2)

sound:Play()

**

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Try this: script.Parent.Chasing.Changed:Connect(function() if script.Parent.Chasing.Value == true then

game.Workspace.Monster6.HumanoidRootPart.footsteps2:Play()

or

script.Parent.Chasing.Changed:Connect(function() if script.Parent.Chasing.Value == true then

workspace.Monster6.HumanoidRootPart.footsteps2:Play()

Ad
Log in to vote
0
Answered by 3 years ago

ok. Please use a code block next time you're including code in your question to make it readable.

Firstly, you create a variable to the path of the boolValue and of the sound:

local boolValue = --the path to the bool value
local sound = --the path to the sound you want to play



Next, you create an event to detect change in the boolValue's value:

local boolValue = --the path to the bool value
local sound = --the path to the sound you want to play

boolValue:GetPropertyChangedSignal("Value"):Connect(function()

if boolValue.Value then

sound.Value:Play()

end


end)

I dont know why ur code isn't working, maybe mine will. GL

Answer this question