Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help, why this script is not doing what it's supposed to do?

Asked by
Suamy 68
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
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.

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 scottmike0 40 — 8y
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. scottmike0 40 — 8y

Answer this question