So I tested this out by pressing F6 and going into test mode, and it works in that, however it doesn't work when I play it in an actual server. Any idea why?
Here is my code:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character
if not character or character.Parent == nil then
repeat wait() until character ~= nil
end
local selection = Instance.new("SelectionBox",player.PlayerGui)
selection.Color = BrickColor.new("Medium stone grey")
local character = player.Character
local valid_target = character.valid_target
mouse.Icon = "http://www.roblox.com/asset/?id=184642130"
mouse.Move:connect(function()
local target = mouse.Target
if target ~= nil then
local hum = target.Parent:FindFirstChild("Humanoid")
local enemy = target.Parent:FindFirstChild("enemy")
local player = target.Parent:FindFirstChild("player")
local book = target.Parent:FindFirstChild("book")
local friend = target.Parent:FindFirstChild("friend")
if hum and target.Parent:IsA("Model") and not player and enemy then
mouse.Icon = "http://www.roblox.com/asset/?id=165194824"
selection.Adornee = target.Parent
valid_target.Value = true
elseif hum and target.Parent:IsA("Model") and not player and book then
mouse.Icon = "http://www.roblox.com/asset/?id=186747208"
selection.Adornee = target.Parent
valid_target.Value = true
elseif hum and target.Parent:IsA("Model") and not player and friend then
mouse.Icon = "http://www.roblox.com/asset/?id=186749391"
selection.Adornee = target.Parent
valid_target = true
elseif hum and target.Parnet:IsA("Model") and player then
mouse.Icon = "http://www.roblox.com/asset/?id=186750107"
selection.Adornee = target.Parent
valid_target = true
else
mouse.Icon = "http://www.roblox.com/asset/?id=184642130"
selection.Adornee = nil
end
else
mouse.Icon = "http://www.roblox.com/asset/?id=184642130"
selection.Adornee = nil
end
end)

2 comments
Is this in a LocalScript?
Yes.