function run(stamina)
if player.maxWalkSpeed == sprintingSpeed then
stamina = stamina - 50
if stamina <= 0 then
Canrun = false
player.maxWalkSpeed = baseSpeed
end
end
end
function Tick(deltaTime)
run(stamina)
end
Error running Lua task: [ED086C801D5465ED] MyScript:10: attempt to index a nil value (global 'player')
Tick function has stopped running. Script: "MyScript", Asset ID: ED086C801D5465ED
What is the problem? so easy and I haven't found out in three days, how this piece of shit engine works. godot works, unity works, it's totally illogical who thinks like that : programming language
You need to define player. What player are you talking about? I would recommend doing a loop through all players like so:
function run(stamina)
for _, player in pairs(Game.GetPlayers()) do
if player.maxWalkSpeed == sprintingSpeed then
stamina = stamina - 50
if stamina <= 0 then
Canrun = false
player.maxWalkSpeed = baseSpeed
end
end
end
end
function Tick(deltaTime)
run(stamina)
end
Thank you for help, basically no error but somehow this script does not run first, I'll change "baseSpeed'' to less and no arguments just only after shift is pressed, and the condition does not work nor is updated on "Canrun" so i can run all the time.