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()”
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