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

A nil value?

Asked by 8 years ago

So I am making a scanner that scans things at tells them if the object he clicked on is harmful, the name of it, and the color of it. But for some reason, in the output, it says "Player a nil value", why is that?

local scanner = script.Parent
local playerMouse = script.Parent.Parent.Parent:GetMouse()

script.Parent.Equipped:connect(function()
    local scanGui = game.ServerScriptService.Scanner:Clone() --Dont judge me please, I store things in the server script service :/
    wait(0.1)
    local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent)--Problem
    scanGui.Parent = player.PlayerGui
    script.Parent.Activated:connect(function(mouse)
        local obj = playerMouse.Target
        scanGui.Frame.Object.Text = "Object: "..obj.Name
        local findPoison = obj:FindFirstChild("isPoisoned") --Finds the value within the object
        if findPoison then
            if findPoison.Value == true then
                scanGui.Frame.Harmful.Text = "Harmful: True"
            elseif findPoison.Value == false then
                scanGui.Frame.Harmful.Text = "Harmful: False"
            end
        elseif not findPoison then
            scanGui.Frame.Harmful.Text = "Harmful: False"
        end
        scanGui.Frame.Color.text = "Color"..obj.BrickColor
    end)
end)

Answer this question