So my game is not working for some reason… heres why.
So everything works. But there is this error that prints out in the console, and the error is
Infinite yield possible on 'Workspace.Roads.RoadPreset.Road:WaitForChild("Humanoid")'
in which NONE of my scripts are even close to having to do with it. It didn’t say which script it was happening in, just said that the error was made in studio.
This error usually comes up when I reset my character a few times.
Even when I try to test it when I publish it, it still works. But same thing keeps happening. Could this just be a bug or is there something really wrong in my scripts?
That’s a warning not an error, if you open the output window in studio you should be able to click on the warning and it’ll take you to the script where the warning occurred from.
When running the game search “script” in your explorer and it’ll show you all the scripts in your game. Maybe a plugin has injected a script? Does your hat contain a script?
Run your game, press Shift + F and insert this in the bar: Workspace.Roads.RoadPreset.Road:WaitForChild(“Humanoid”). It should show all scripts with this line of code.
Under neath the warning in the Output there should be 3-4 lines of blue text. They should include the script and the line, when you click on one of them it will take you to the script throwing the warning.
Is this script the local tool script or a server script? Any damage done to enemies on the client will remain client sided.
You also have no check IF the object has a humanoid, you just assume it has one and wait for it forever. I also think you do not have a debounce if it keeps happening so fast.
What you have to do is first check if it has a humanoid, then set a debounce so your code doesnt repeat 1000 times:
local debounce = false -- declare a debounce at the beginning of your script
---
local hum = Hit.Parent:FindFirstChild("Humanoid") -- on your tool attack, try to get the humanoid
if hit and debounce == false then -- if we arent already attacking and a humanoid exists then take their HP mwahahaha
debounce = true
-- do your server fire take action codey bits
debounce = false -- make sure to reset it after you have done your attack
else
return -- this enemy cannot even take damage cause its a wall or something
end