Help With Detection Script?
03 | local player = game.Players.LocalPlayer |
04 | local plr = game.Players.LocalPlayer.Character |
07 | if player.HatEquiped.Value ~ = "Empty" then |
08 | for i,v in pairs (plr:GetChildren()) do |
09 | if v.ClassName = = "Hat" then |
10 | local verification = v:FindFirstChild( "HatVerifier" ) |
12 | local hatwearing = v.Name |
13 | if player.HatEquiped.Value ~ = hatwearing then |
15 | local hatnowwearing = game.ReplicatedStorage:FindFirstChild( "" ..player.HatEquiped.Value.. "" ):Clone() |
17 | hatnowwearing.Parent = plr |
20 | elseif verification = = nil then |
21 | local hatnowwearing = game.ReplicatedStorage:FindFirstChild( "" ..player.HatEquiped.Value.. "" ):Clone() |
23 | hatnowwearing.Parent = plr |
The specific issue is on line 21, it says that it's trying to detect a nil value
Basically, this is a script for character customization in my game. Each hat in my game has a value in it to distinguish it from Roblox Avatar hats. In line 21 it tries to make a value to Clone a hat from Replicated Storage if it's name is the same as the value of the hat that the character is supposed to be wearing. I tried to use FindFirstChild so that it wouldn't have the issue, but it is anyways. Help?