What did I do wrong in this script to give the nil value?

After a few hours I’m starting to fail from stress, here’s the script:
local P = game:GetService(“Players”)
local SS = game:GetService(“ServerStorage”)

P.PlayerAdded:Connect(function(player)
SS.ClonableFiles.CheckTool:Clone().Parent = player
player.CharacterAdded:connect(function(char)
SS.ClonableFiles.CharacterTools:Clone().Parent = char
end)
end)

–Get True parts

P.PlayerAdded:Connect(function(player)
player.CharacterAdded:connect(function(char)
char.CharacterTools.Test.Part0 = char.Head
end)
end)

–Check if true or false(module script)
wait(4)
local function check()
P.PlayerAdded:Connect(function(player)
player.CharacterAdded:connect(function(char)
while SS.Crasher.Value == true do
if char.CharacterTools.Test.Part0 == “Head” then
print(“sucess”)
else
print(“nil”)
end
wait()
end
end)
end)
end

check()

For some reason instead of printing “success” it will print “nil”, I don’t understand what I did wrong because the value of Part0 should be Head and is assuming as nil

image

Note: weldContrains is nil at the beginning but then in the scritt he puts Part0 as “Head”

What did I do wrong?

You are comparing an object to a string.

char.CharacterTools.Test.Part0 == “Head” 

It should be the following instead.

char.CharacterTools.Test.Part0.Name == “Head” 
1 Like