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

why the heck mouse a nil value im using Script im just doing filtering enabled thingy?

mouse.KeyDown:connect(function(key) if key == "t" and mouse.Target then local hum = mouse.Target.Parent:FindFirstChildOfClass('Humanoid') if hum == nil then hum = mouse.Target.Parent.Parent:FindFirstChildOfClass('Humanoid') end if curpoint == nil then if hum and hum.Parent:FindFirstChild('Head') then curpart = hum.Parent.Head else

3 comments

0

What does the error say?

0

man u cant just grab client data from a server script u need to pass it thru a remote event

0

woah use a code block (select your code in the question editor and press the little lua icon)

1 answer

✓ Accepted answer

Well I can't see the full length of your script, however I can note that KeyDown is deprecated in favor of the UserInputService and connect is deprecated in favor of Connect.

REVISION (LocalScript Only)

local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local curpoint = nil
local curpart = nil

game:GetService("UserInputService").InputBegan:Connect(function(input, event)
	if input.KeyCode == Enum.KeyCode.T and mouse.Target ~= nil then
		local hum = mouse.Target.Parent:FindFirstChildOfClass("Humanoid")
		if hum == nil then
			hum = mouse.Target.Parent.Parent:FindFirstChildOfClass("Humanoid")
		end
		if curpoint == nil then
			if hum and hum.Parent:FindFirstChild("Head") then
				curpart = hum.Parent.Head
			else
			end
		end
	end
end)

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