local player = game.Players.LocalPlayer
local mouse = player:GetMouse() --Getting the player's mouse

mouse.Move:connect(function() --When the mouse moves
	local target = mouse.Target
	local selection = Instance.new("SelectionBox", player.PlayerGui)
		selection.Name="Jerry"
		selection.Color = BrickColor.new("Cyan")
		if mouse.Target.Name=="JerryBlock" and mouse.Target:IsA("BasePart") then
		selection.Adornee=target
		else
			player.PlayerGui.Jerry.Adornee=nil
		end
end)
			

This is supposed to add a selection box around a an NPC. JerryBlock is a Part that I put inside the NPC's model.

The only thing not working is that the selection box wont disappear when the mouse exits.

The script is a LocalScript in StarterPlayerScripts. This is a portion of the script.

2 comments

0

http://wiki.roblox.com/index.php?title=How_to_use_a_SelectionBox * remove mouse.Target:IsA("BasePart") selection.Adornee = target.Parent Because you are trying to make the whole model to have the selection box, and use this as else statement, selection.Adornee = nil

0

the remove part is where you have the and statement * mouse.Target:IsA("BasePart")" and put selection.adornee = target.parent as the statement underneath it instead.