'System.Type' Error, with FootStep Script.

Ok i found this script while searching, it’s excatly what i need but i have an issue with it. I created each “Tag” already and marked the aproperate Objects with said tags.
And i made the Sound file for each defenition in the script, but it comes up with this error on lines 43,56,69, 83.

PlayerFootSteps.js(43,24): BCE0048: Type ‘System.Type’ does not support slicing.

Here is the script, what do i need to change/update to remove that error?

    //Credit it TMR for script
    
    var delayBeforeSteps : float = 0.20;
    var delayBetweenSteps: float = 0.45;
    var audioStepLength : float = 0.60;
    var groundType : int;
    var isPlayerWalking : float = 0.0;
    
    //Sound Files
    var stepSand = AudioClip;
    var stepCarpet = AudioClip;
    var stepGround = AudioClip;
    var stepWood = AudioClip;
    var stepStone = AudioClip;
    var stepWater = AudioClip;
    var stepFall = AudioClip;
    
    var footAudioRandomness = 0.1;
    var soundEffectPitchRandomness = 0.05;
     
    function Update()
    {
    //Check to see if the player is walking by checking for input from the walking keys
    if(Input.GetButton("Horizontal") || Input.GetButton("Vertical"))
    {
    //if those keys are pressed, the player must be walking...
    isPlayerWalking += Time.deltaTime;
    }
    else
    {
    //if those keys aren't pressed, the player can't be walking.....
    isPlayerWalking = 0;
    }
    }
     
    function Start()
    {
    var aSources = GetComponents(AudioSource);
    footSource1 = aSources[0];
     
    while(true)
    {
    if (isPlayerWalking >= 0.20 && groundType == 1)
    {
    yield WaitForSeconds(delayBeforeSteps);
    footSource1.clip = stepSand[Random.Range(0, stepSand.length)];
    footSource1.volume = Random.Range(0.4 - footAudioRandomness, 0.4 + footAudioRandomness);
    footSource1.pitch = Random.Range(1.0 - soundEffectPitchRandomness, 1.0 + soundEffectPitchRandomness);
    footSource1.Play();
     
    if(isPlayerWalking == 0)
    {
    yield;
    }
    }
    else if ( isPlayerWalking >= 0.20 && groundType == 2)
    {
    yield WaitForSeconds(delayBeforeSteps);
    footSource1.clip = stepWood[Random.Range(0, stepWood.length)];
    footSource1.volume = Random.Range(0.4 - footAudioRandomness, 0.4 + footAudioRandomness);
    footSource1.pitch = Random.Range(1.0 - soundEffectPitchRandomness, 1.0 + soundEffectPitchRandomness);
    footSource1.Play();
     
    if(isPlayerWalking == 0)
    {
    yield;
    }
    }
    else if ( isPlayerWalking >= 0.20 && groundType == 3)
    {
    yield WaitForSeconds(delayBeforeSteps);
    footSource1.clip = stepStone[Random.Range(0, stepStone.length)];
    footSource1.volume = Random.Range(0.4 - footAudioRandomness, 0.4 + footAudioRandomness);
    footSource1.pitch = Random.Range(1.0 - soundEffectPitchRandomness, 1.0 + soundEffectPitchRandomness);
    footSource1.Play();
     
    if(isPlayerWalking == 0)
    {
    yield;
    }
    }
     
    else if (isPlayerWalking >= 0.20 && groundType == 4)
    {
    yield WaitForSeconds(delayBeforeSteps);
    footSource1.clip = stepGround[Random.Range(0, stepGround.length)];
    footSource1.volume = Random.Range(0.4 - footAudioRandomness, 0.4 + footAudioRandomness);
    footSource1.pitch = Random.Range(1.0 - soundEffectPitchRandomness, 1.0 + soundEffectPitchRandomness);
    footSource1.Play();
     
    if(isPlayerWalking == 0)
    {
    yield;
    }
    }
    else if ( isPlayerWalking >= 0.20 && groundType == 5)
    {
    yield WaitForSeconds(delayBeforeSteps);
    footSource1.clip = stepCarpet[Random.Range(0, stepCarpet.length)];
    footSource1.volume = Random.Range(0.4 - footAudioRandomness, 0.4 + footAudioRandomness);
    footSource1.pitch = Random.Range(1.0 - soundEffectPitchRandomness, 1.0 + soundEffectPitchRandomness);
    footSource1.Play();
     
    if(isPlayerWalking == 0)
    {
    yield;
    }
    }
    else if ( isPlayerWalking >= 0.20 && groundType == 6)
    {
    yield WaitForSeconds(delayBeforeSteps);
    footSource1.clip = stepWater[Random.Range(0, stepWater.length)];
    footSource1.volume = Random.Range(0.4 - footAudioRandomness, 0.4 + footAudioRandomness);
    footSource1.pitch = Random.Range(1.0 - soundEffectPitchRandomness, 1.0 + soundEffectPitchRandomness);
    footSource1.Play();
     
    if(isPlayerWalking == 0)
    {
    yield;
    }
    }
    else
    {
    yield;
    }
    }
    }
     
    function OnControllerColliderHit (hit : ControllerColliderHit)
    {
    if (hit.gameObject.tag == "sandFloor")
    {
    groundType = 1;
    print("Sand");
    }
    else if (hit.gameObject.tag == "woodFloor")
    {
    groundType = 2;
    print("Wood");
    }
    else if (hit.gameObject.tag == "stoneFloor")
    {
    groundType = 3;
    print("Stone");
    }
    else if (hit.gameObject.tag == "groundFloor")
    {
    groundType = 4;
    print("Ground");
    }
    else if (hit.gameObject.tag == "carpetFloor")
    {
    groundType = 5;
    print("Carpet");
    }
    else if (hit.gameObject.tag == "waterFloor")
    {
    groundType = 6;
    print("Water");
    }
    }

Update: If you get pissed about the tags i tried to make it about this posrt but it kept telling me (you must have at least 50 reputation to create) Compile, Error, Question…

1 Answer

1

See the answer I gave here. You’re error is bce0048 and there are other questions on the same thing. Once you have read my answer, then look at you variable declarations around line 10 in the question, and you’ll see that they are all untyped. So, at line 112 in the script you provide, you’ll see you are trying to treat stepWater as an array, but you’ve not declared it as an array. Well, you’ve not provided any type at all. Perhaps you meant a : and not an =?

Hey sorry for the late reply, i have Gout in my foot so i had a hell of a time getting to my PC. I made the appropriate changes and fixes this morning and now it's working, hard part is making the footSteps MP3's now lol. (i was testing it with free ones) But thanks Rep+, or that Thumbs up thing, i think that's rep.