BrickColor Stepping SFX "system"

Currently I’m trying to script a script that uses animation events to determine when I should raycast from a humanoid root part to a part underneath the player, then returns with the brickcolor of the part that intersected with the raycast and go through a folder named “StepSFX” looking for sound effects for each color.

The issue is with looking for the sound effects for each color. I tried this, but it returns
“Unable to cast value to std::string” from “StepSFX:WaitForChild(raycastresult.Instance.BrickColor):Play()”

I also tried this, but despite printing the same words, it doesnt go through the if statement.


image

Ignore the fact its in a local script, I had 2 scripts and one was a server script, and one was a local script. I think I accidently clicked the local script.

I’d suggest creating a dictionary to store what sound to make when a certain color is found.
For example:

local dictionary = {
     ["Dark stone grey"] = SoundFX.stoneWalkSound
}

dictionary[Raycast.Result.Instance.BrickColor:[Convert to string function here]()]:Play()
-- Depending on the color, the sound will be played
1 Like

im still relatively new to scripting and i don’t know what you mean by “Convert to string function here” i know what a string is, but im confused

I think he ment this

dictionary[tostring(Raycast.Result.Instance.BrickColor)]:Play()

I also recommend changing your params.FilterDescendantsInstances to {Character} instead because it will already ignore everything in character

2 Likes

oh thats what he ment. dont really use those often at all lol

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.