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

I have a problem with an error and i dont know what it means anyhelp?

this shouldent give me an error

	script.Parent.Position = UDim2.new(0,Mouse.X - 100,0,Mouse.Y + 60)
	if Mouse.Target == nil or (Mouse.Target.Position - Player.Character.Torso.Position).magnitude > 7 then script.Parent.Visible = false
	elseif Mouse.Target ~= nil and (Mouse.Target.Position - Player.Character.Torso.Position).magnitude < 7 then

ERROR

14:03:55.938 - Players.ObStactionD3stroy3r.PlayerGui.MouseTrack.Frame2.LocalScript:9: attempt to index field 'Target' (a nil value)

2 answers

✓ Accepted answer

Hey, @TheRevealerYT , I would like you to check this page of the Roblox Wiki :

http://wiki.roblox.com/index.php?title=Lua_errors

This wikipedia article is very usefull when you don't really know what error is that or how to fix a specific erorr. Hope this helped and, try to search more in google! If you searched a bit more , you would found this page and found your error and the direct fix to it.

local popup = script.Parent;
local target = Mouse.Target;
local char = player.Character;

popup.Position = UDim2.new(0, (Mouse.X - 100), 0, (Mouse.Y + 60));

if (target and char) then
	-- To check for the distance we have to have the target's position, so it can't be nil.
	local dist = player:GetDistanceFromCharacter(target.Position);
	popup.Visible = (dist > 7) and false or true; -- ProTip: this is a Terenary Operator, it's the same as saying if dist > 7 then popup.Visible = false else popup.Visible = true end
else
	popup.Visible = false;
end

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