Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does line 31 of my script think the value of hrp's velocity is not a vector3? [Solved]

My script i wrote to stop time does not like line 31. Apparently the value that got stored for is a nil and not a vector3 so when line 31 tries to use it to give humanoidrootparts back their velocity it just gives back a nil value. the script is written as follows.

game.ReplicatedStorage.StopTime.OnServerEvent:Connect(function()
	game.Lighting.timestoplight.Enabled = true
	local tablo = game.Workspace:GetDescendants()
	for i,v in next, tablo do
		local function thread()
			if v.Name == "Part" then
				ank = v.Anchored
				vel = v.Velocity
				v.Anchored = true
				v.Velocity = Vector3.new(0,0,0)
			end
		end
		local function thread2()
			if v.Name == "HumanoidRootPart" then
				ank2 = v.Anchored
				vel2 = v.Velocity
				v.Anchored = true
				v.Velocity = Vector3.new(0,0,0)
			end
		end
		spawn(thread)
	end
end)
game.ReplicatedStorage.EndStopTime.OnServerEvent:Connect(function()
	game.Lighting.timestoplight.Enabled = false
	local tablo = game.Workspace:GetDescendants()
	for i,v in next, tablo do
		local function thread2()
			if v.Name == "HumanoidRootPart" then
				v.Anchored = ank2
				v.Velocity = vel2
			end
		end
		local function thread()
			if v.Name == "Part" then
				v.Anchored = ank
				v.Velocity = vel
			end
		end
		spawn(thread)
		spawn(thread2)
	end
end)

1 answer

it appears i forgot to thread the second thread in the function for when timestop begins

This discussion is preserved as it was. New answers, comments, and votes are closed.