I’m making a selectionbox script but it isn’t showing up on the adornee
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local selection = Instance.new("SelectionBox")
selection.Color3 = Color3.new(0.6,0.6,0.6)
selection.Parent = player.PlayerGui
mouse.Move:Connect(function()
local target = mouse.Target
if (target) and target.Name == "ClickPart" and target.Parent == script.Parent.Parent then
selection.Adornee = script.Parent
else
selection.Adornee = nil
end
end)
Changed the parent to workspace, still doesn’t show up, no errors.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local selection = Instance.new("SelectionBox")
selection.Color3 = Color3.new(0.6,0.6,0.6)
selection.Parent = workspace
mouse.Move:Connect(function()
local target = mouse.Target
if (target) and target.Name == "ClickPart" and target.Parent == script.Parent.Parent then
selection.Adornee = script.Parent
else
selection.Adornee = nil
end
end)
I’m gonna assume that this LocalScript is inside of a part in the workspace. LocalScripts are not allowed to run in the workspace, only in the locations listed below:
I’d wouldn’t reccomend putting the LocalScript within ReplicatedFirst, since that would result in some other issues and force you to use uncessary :WaitForChild()s.
Put the LocalScript inside StarterGui, then just replace “script.Parent.Parent” inside target.parent == script.Parent.Parent then with the part that it was referencing before. Also, SelectionBoxes don’t need to be parented to the workspace, but it’s a valid option (along with the PlayerGui)
Just adding on to your last point, wouldn’t parenting them to workspace affect it server-side?
09:18:46.013 Infinite yield possible on 'Untitled Game @ 21 Mar 2021 09:18:WaitForChild("Uniforms")' - Studio returns for
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local selection = Instance.new("SelectionBox")
selection.Color3 = Color3.new(0.6,0.6,0.6)
selection.Parent = workspace
local UniformModels = game:WaitForChild("Uniforms")
mouse.Move:Connect(function()
local target = mouse.Target
if (target) and target.Name == "ClickPart" and target.Parent == UniformModels then
selection.Adornee = script.Parent
else
selection.Adornee = nil
end
end)
Thats odd. Could Uniforms have a trailing space or something?
Also try moving the LocalScript to the StarterGui if you have it in ReplicatedFirst. Your script doesn’t need to be in ReplicatedFirst since it doesn’t need to be ran as soon as possible.