Local Script thinks the player is in the wrong position

This problem is a literal nightmare for me now
I CANT FIX IT NO MATTER WHAT I DO!!

The Local Script thinks the player is still falling, BUT HES NOT!

repeat wait() until game:IsLoaded() == true

local RespawnSystem = workspace:FindFirstChild('RespawnSystem')
local RefreshEvent = RespawnSystem:FindFirstChild('RefreshPlayer')
local Camera = workspace.CurrentCamera

local CriticalHeightBlock = RespawnSystem:FindFirstChild('CriticalHeight')
local RespawnignOnServer = RespawnSystem:FindFirstChild('RespawningEnabledServer')

local RunService = game:GetService('RunService')
local TweenService = game:GetService('TweenService')

local Players = game:GetService('Players')
local Player = Players.LocalPlayer
local Character = Player.Character

local PrimaryPart:BasePart = Character:FindFirstChild('HumanoidRootPart')
local FallDebounce = false

local CameraLooking = false

Player.CharacterAdded:Connect(function(char)
	wait(2
	)
	FallDebounce = false
end)

task.spawn(function()
	while wait(0.1) do
		local RaycastParamsCharacter = RaycastParams.new()
		RaycastParamsCharacter.FilterType = Enum.RaycastFilterType.Exclude
		RaycastParamsCharacter.FilterDescendantsInstances = {Character}

		local RaycastingResult = workspace:Raycast(PrimaryPart.Position, Vector3.new(0,-900,0), RaycastParamsCharacter)


		if not RaycastingResult then
			if PrimaryPart.Position.Y <= CriticalHeightBlock.Position.Y and FallDebounce == false then

				if FallDebounce == false then
					FallDebounce = true

					script.Parent.Scream:Play()

					repeat wait()
						Camera.CameraType = Enum.CameraType.Scriptable

					until
					Camera.CameraType == Enum.CameraType.Scriptable
					
					CameraLooking = true
					
					task.spawn(function()
						while wait() do
							if CameraLooking == true then
								TweenService:Create(Camera, TweenInfo.new(0.07, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0), {CFrame = CFrame.lookAt(Camera.CFrame.p, PrimaryPart.Position)}):Play()
							end
						end
					end)
					
					wait(2)
					CameraLooking = false
					RefreshEvent:FireServer()
					Camera.CameraType = Enum.CameraType.Custom
					
					PrimaryPart.Position = PrimaryPart.Position
					
					task.spawn(function()
						wait(20)
						--FallDebounce = false
					end)
				end
			end
		end
	end
end)

When the player is falling down, its supposed to respawn him. It does the job, but once he respawns. THE GAME STILL THINKS HES THERE :sob:

I dont know what to do at this point.

Any help would be appreciated

An Idea:

--Rest of the above code..
Player.CharacterAdded:Connect(function(char)
	task.wait(2)
    Character = Player.Character
    PrimaryPart = Character:FindFirstChild('HumanoidRootPart')
	FallDebounce = false
end)
--Rest of Code...

What I think is happening is your mentioning the Old, dead character, and so when the character respawns, you need to refresh your variables to show that change. This is my best guess to whats happening atleast… Let me know if it still happens, or if it errors?

1 Like

thanks alot bro, you really helped me out :+1:

1 Like

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