Help, why this script is not doing what it's supposed to do?
Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
04 | mouse.Move:connect( function () |
05 | local target = mouse.Target |
06 | local selection = Instance.new( "SelectionBox" , player.PlayerGui) |
07 | selection.Name = "Jerry" |
08 | selection.Color = BrickColor.new( "Cyan" ) |
09 | if mouse.Target.Name = = "JerryBlock" and mouse.Target:IsA( "BasePart" ) then |
10 | selection.Adornee = target |
12 | player.PlayerGui.Jerry.Adornee = nil |
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.