I had this script running okay, then I made some changes which I want to do, and now it just isn't working, and I seriously don't know why. It throws this error:
20:47:03.109 - Players.Player1.PlayerGui.mouse_runner:58: attempt to index upvalue 'valid_target' (a boolean value) 20:47:03.110 - Stack Begin 20:47:03.110 - Script 'Players.Player1.PlayerGui.mouse_runner', Line 58 20:47:03.111 - Stack End
Here's my code:
repeat wait() until game.Players.LocalPlayer.Character and game.Players.LocalPlayer
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local selection = Instance.new("SelectionBox",player.PlayerGui)
selection.Color = BrickColor.new("Medium stone grey")
local valid_target = player.valid_target
local current_target = player.current_target
mouse.Icon = "http://www.roblox.com/asset/?id=187412806"
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 and current_target.Value ~= target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187412859"
selection.Adornee = target.Parent
valid_target.Value = true
elseif hum and target.Parent:IsA("Model") and not player and enemy and current_target.Value == target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187412859"
selection.Adornee = target.Parent
valid_target = true
end
if hum and target.Parent:IsA("Model") and not player and book and current_target.Value ~= target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187412830"
selection.Adornee = target.Parent
valid_target.Value = true
elseif hum and target.Parent:IsA("Model") and not player and book and current_target.Value == target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187412830"
selection.Adornee = target.Parent
valid_target.Value = true
end
if hum and target.Parent:IsA("Model") and not player and friend and current_target.Value ~= target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187412846"
selection.Adornee = target.Parent
valid_target.Value = true
elseif hum and target.Parent:IsA("Model") and not player and friend and current_target.Value == target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187412846"
selection.Adornee = target.Parent
valid_target.Value = true
end
if hum and target.Parent:IsA("Model") and player and current_target.Value ~= target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187425092"
selection.Adornee = target.Parent
valid_target.Value = true
elseif hum and target.Parent:IsA("Model") and player and current_target.Value == target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187425092"
selection.Adornee = target.Parent
valid_target.Value = true
end
if not hum or current_target.Value ~= target.Parent then
mouse.Icon = "http://www.roblox.com/asset/?id=187412806"
selection.Adornee = nil
valid_target.Value = false
end
else
mouse.Icon = "http://www.roblox.com/asset/?id=187412806"
selection.Adornee = nil
valid_target.Value = false
end
end)
I'm really having trouble on this, so any help is much appreciated! Thanks for reading!

1 comment
This helps a lot! I REALLY appreciate this, I will apply this whenever I'm scripting. I'm sorry for my code, it usually becomes a lot longer than it really needs to.