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]