I’m currently making a unique assassins sword where when you equip it you are given a target to kill. When a target is found, a value named TargetValue is set to the targets name. When the sword is touched by a humanoid, the following if statement is written in the code. To see if there is a target or not I have used if TargetValue.Value == “” --do stuff elseif TargetValue.Value ~= “” --do stuff. Although when TargetValue.Value holds the name of a player, “player not detected” is printed (see the following code)
if TargetValue.Value ~= "" then
print("player detected")
Player_Target = true
Other_Target = false
if Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Name == TargetValue.Value then
EnemyHumanoid = Hit.Parent:WaitForChild("Humanoid")
elseif Hit.Parent.Parent:FindFirstChild("Humanoid") and Hit.Parent.Parent.Name == TargetValue.Value then
EnemyHumanoid = Hit.Parent.Parent:WaitForChild("Humanoid")
else return end
elseif TargetValue.Value == "" then
print("player not detected")
Player_Target = false
Other_Target = true
if Hit.Parent:FindFirstChild("Humanoid") then
EnemyHumanoid = Hit.Parent:WaitForChild("Humanoid")
elseif Hit.Parent.Parent:FindFirstChild("Humanoid") then
EnemyHumanoid = Hit.Parent.Parent:WaitForChild("Humanoid")
else end
else end
if anyone could help that would be great. I can also provide the tool for fixing which would be appreciated