Issues with Visionaire Studio 5 - Need Help with Scripting Errors

  • #1, von priyalMontag, 26. August, 09:52 Uhr vor 3 Wochen
    Hi everyone,

    I’m experiencing some difficulties with Visionaire Studio 5 and could use some help. I’ve been working on a project, and I keep encountering scripting errors that I can’t seem to resolve. Specifically, I’m having trouble with a script that handles character movement and interactions.

    Here’s a brief overview of the issue:

    Error Message: Script Error: Undefined variable 'playerX' on line 42

    Script Code: 
    -- Function to move the player character
    function movePlayer()
        local speed = 5
        if inputIsPressed("right") then
            playerX = playerX + speed
        elseif inputIsPressed("left") then
            playerX = playerX - speed
        end
        setCharacterPosition(playerX, playerY)
    end
    -- Initialize player position
    playerX = 100
    playerY = 200
    -- Update loop
    function update()
        movePlayer()
    end

    What I’ve Tried: I’ve checked the syntax and tried to debug using the built-in tools, but the issue persists. It seems like the variable playerX might not be properly initialized or is somehow being undefined during runtime.

    Has anyone faced a similar problem or have any suggestions on how to fix this? Any help or guidance would be greatly appreciated!

    Thanks!
    snowflake
    [code][/code]

    Neuling

    3 Posts


  • #2, von afrlmeDienstag, 27. August, 15:50 Uhr vor 3 Wochen
    It would probably help if you included the entire script as the error you mentioned says line 42 & you've only posted a handful of lines.

    Also, I'm not familar with that error warning. If I try to access a variable that doesn't exist it just returns nil.

    Foren Imperator

    7285 Posts

Beitrag schreiben