CFrame not updating

CFrame not updating

I made a monster that moves closer to you when you’re tabbed out of roblox, this worked yesterday, but it suddenly stopped working even though I haven’t changed anything.

I have tried using a pcall and added a print(“success”) at the end of the pcall, it reaches the “success” and yet it doesn’t update the cframe.

Here’s my code

		repeat
			local success, errormsg = pcall(function()
				wait(0.1)
				local PlayerHumanoid = monster
				local TargetHumanoid = game.Players.LocalPlayer.Character.HumanoidRootPart
				print(game.Players.LocalPlayer.Character.Name)

				local LastTargetPosition = TargetHumanoid.CFrame
				--- The CFrame below doesn't update
				PlayerHumanoid.CFrame = LastTargetPosition + LastTargetPosition.LookVector * Length
				PlayerHumanoid.CFrame = CFrame.new(PlayerHumanoid.CFrame.Position, Vector3.new(LastTargetPosition.Position.X, PlayerHumanoid.CFrame.Position.Y, LastTargetPosition.Position.Z))
				print("success")
			end)
			if not success then
				warn(errormsg)
			end
		until
		IsFocusedOnWindow or Length > -1
		if Length >= -1 then
			jumpscare:Play()
			errorsound:Play()
			script.ColorCorrection.Parent = game.Lighting
			game.Players.LocalPlayer.Character.Humanoid.Health = 0
			monster:Destroy()
			game.Players.LocalPlayer:Kick("An unexpected error has occurred.")
		end
	end)
	if not succ then
		warn(err)
	end

I hope anyone has a fix for this, it was working perfectly fine and now it suddenly stopped working.

2 Likes

Can you show the part where you are checking for the focused window? It could also be your Length variable, I am not sure how you are updating that.

3 Likes

Thanks for telling me that, I guess that line somehow got lost when I published the game.
Guess that bug exists in roblox.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.