Tool cant get value inside players character

Im trying to make a tool combat which includes stunning,like if your stunned you wont be able to attack,but whenever i try to test it gives a error.
Players.adcrs.Backpack.Disamble.Script:10: attempt to index nil with 'Value'
Im trying to get a intvalue which is in player’s character and trying to check if its 1.

tool.Activated:Connect(function(Player)
	local clo = char:FindFirstChild("isGettingComboed").Value
	if clo == 0  then

Help will be appriciated :grinning_face_with_smiling_eyes:

2 Likes

When using FindFirstChild(), I recommend using something like this to avoid errors.

local val= char:FindFirstChild("isGettingComboed")
if val then
    local clo = val.Value
    if clo == 0 then
        -----code
    end
else
    print("No Value Found")
end

As for your main issue, your script can’t find a value inside the Character called “isGettingComboed”. Make sure to check for spelling errors (both in the script and the value) and when ingame, check in the character to see if the Value is even there, because it could be an issue elsewhere.

I’m also fairly certain that Player isn’t a parameter of Activated. Anybody feel free to correct me if I’m wrong.

2 Likes

The value is there but still its like showing that value not found?also for the character im doing
script.Parent.Parent which is the player model in workspace

Right, so I think your problem may be your character then.

Are you defining your character before the tool is equipped? If so it’s possible you could be searching the Player rather than the Character.

If this is a case then I would do something like this:

local char = nil
tool.Equipped:Connect(function()
   char = script.Parent.Parent
end)

This would make sure that it only gets the character when the script is a descendant of the character. You could also do tool.Parent.

Personally I wouldn’t always use script.Parent.Parent to get the character, but I suppose it doesn’t matter too much. Also last thing, make sure when you activate the tool, to check if the char is nil, if it is then return or attempt to define it (tool.Parent)

3 Likes

Oh yeah ,i forgot that ,thanks so much :grinning_face_with_smiling_eyes:

You’re very welcome! Be sure to mark as solution if this solved your problem for anyone else coming across the same issue.

Happy to help.