Why is this happening?

As you can see in the video, “ended (x)” just keeps on counting up. Theres a bug in my game that occurs after the “ended (x)” starts to rapidly count up. What causes this? Theres no errors so im not sure whats going on.

Can you provide the script for us to see? We can’t really help much unless we see the script that is causing this.

Sure.

local function itemFloat(tool)
	local handle = tool.Handle
	local anchor = tool.AnchorPart
	spin = RunService.RenderStepped:Connect(function(dt)
		if Destroyed(tool) then
			print('ended')
			spin:Disconnect()
		else
			handle.CFrame = anchor.CFrame * CFrame.new(0, math.sin(tick() * 2), 0) * CFrame.Angles(math.pi / -2, 0, 0)
			anchor.CFrame = anchor.CFrame * CFrame.Angles(0, 3 * dt, 0)
		end
	end)
end

this is where the bug is occuring i think.

the full script is about 70 lines so idk if thats to much to post or not.

Seventy lines aren’t too much to post but provided the specific section was good too. As for the problem, I can’t see any problem with this. Unless you are constantly calling the function “itemFloat,” I don’t think there’s anything wrong with this script. Although this probably won’t fix it, try to make a local variable of spin before creating the connection.

local function itemFloat(tool)
	local handle = tool.Handle
	local anchor = tool.AnchorPart
	local spin
	spin = RunService.RenderStepped:Connect(function(dt)
		if Destroyed(tool) then
			print('ended')
			spin:Disconnect()
		else
			handle.CFrame = anchor.CFrame * CFrame.new(0, math.sin(tick() * 2), 0) * CFrame.Angles(math.pi / -2, 0, 0)
			anchor.CFrame = anchor.CFrame * CFrame.Angles(0, 3 * dt, 0)
		end
	end)
end
1 Like

Ahhh that fixed it! It was working perfect for months without the spin variable. That’s weird. Thank you i really appreciate the help! The bug was occuring when the enemy would drop tools after he dies, one of the tools would always fall through the map but this seems to fix it.

I didn’t think that would be the problem either, but I usually do mine like that so I figured that could fix it. Didn’t know Roblox did that either :sweat_smile:

Exactly. spin always had an error underline but it was nothing that would affect anything in game, but i guess roblox changed something idk.

1 Like