This is a local script that is obviously in a FilteringEnabled = false place. If you cannot tell, it's (currently) a Noclip type of script. The noclip part works, however the second time I use this I receive the error 18:32:27.445 - attempt to call a nil value and It doesn't tell me a line so I could fix it. I assume it's the mouse being nil, if so, why?

Also, while I'm asking a question, the Rotation function is suppose to rotate the character's body (Everything rotates) however, the head is not facing the direction of my mouse in correlation with the whole body. Can I get some help with that as well along with an explanation to why that works? Btw, this is and unfinished code but I cannot go further at it's current condition.

local Plr = game.Players.LocalPlayer
repeat wait() until Plr.Character
local Char = Plr.Character
local Active = false
local Tool = script.Parent
local Mouse = Plr:GetMouse()
local RS = game:GetService("RunService")
local End = false
local BackUpJoint = Char:WaitForChild("HumanoidRootPart"):WaitForChild("RootJoint"):Clone()

function NoClipActivate()
	local Torso = Char:WaitForChild("Torso")
	local Head = Char:WaitForChild("Head")
	Step = RS.Stepped:connect(function()
		Torso.CanCollide = false
		Head.CanCollide = false
	end)
	Change = Char.Torso.Changed:connect(function(Property)
		if Property == "CanCollide" then
			Torso.CanCollide = false
			Head.CanCollide = false
		end
	end)
end

function RotationBegin()
	local CurrentJ = Char.HumanoidRootPart.RootJoint
	while wait() do		
		CurrentJ.C0 = CFrame.new(Char.Head.CFrame.lookVector, Mouse.Hit.p/2) 
	end
end

local Coro = coroutine.create(NoClipActivate)
local Coro2 = coroutine.create(RotationBegin)
Tool.Equipped:connect(function()
	Active = true
	Tool.Unequipped:connect(function()
		Active = false
		BackUpJoint.Parent = Char.HumanoidRootPart
	end)
end)

Mouse.Button1Down:connect(function()
	local Joint = Char:WaitForChild("HumanoidRootPart"):WaitForChild("RootJoint"):Clone()
	if Active then
		coroutine.resume(Coro)
		coroutine.resume(Coro2)
		Mouse.Button1Up:wait()
		coroutine.yield(Coro)
		coroutine.yield(Coro2)
		Char.HumanoidRootPart.RootJoint:Destroy()
		Joint.Parent = Char.HumanoidRootPart
		Change:disconnect()
		Step:disconnect()		
	end
end)

I can provide more information if needed, just comment.

1 comment

0

Not as long as it appears, just lots of white lines <3... Kinda ;3