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

Why does it say "Value is not a valid member of Model", etc. in out put?

Asked by 7 years ago

Why does it say in output: "17:13:42.515 - Value is not a valid member of Model", "17:13:42.515 - Script 'Workspace.Player1.StarterSword.Handle.LocalScript', Line 13", and "17:13:42.515 - Stack End". The NPC has the value inside of him. How can I fix this?

local debounce = false
local player = game.Players.LocalPlayer

function onTouched(hit)
    if not debounce then
        debounce = true
        if hit.Parent.Name:sub(1,17) == "AFK Noob Lv 1 HP " then
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
            if hit.Parent.Humanoid.Health == 0 then
                if hit.Parent.Value == false then 
                    player.leaderstats.EXP.Value = player.leaderstats.EXP.Value + 16 
                end
                hit.Parent.Value = true
            end
            wait(0.5)
            debounce = false
        elseif hit.Parent.Name:sub(1,4) == "Noob" then
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
            wait(0.5)
            debounce = false
        end
    end
end

script.Parent.Touched:connect(onTouched)

1 answer

Log in to vote
1
Answered by 7 years ago

You forgot to set the value to change! Use hit.Parent.Value.Value instead. Also in the if statement it is better practice to use findFirstChild("Value") rather than .value!

Ad

Answer this question