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

Help With Detection Script?

Asked by
Scootakip 299 Moderation Voter
9 years ago
01while true do
02    wait()
03    local player = game.Players.LocalPlayer
04    local plr = game.Players.LocalPlayer.Character
05    if player then
06        if plr then
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")
11                        if verification then
12                            local hatwearing = v.Name
13                            if player.HatEquiped.Value ~= hatwearing then
14                                v:Destroy()
15                                local hatnowwearing = game.ReplicatedStorage:FindFirstChild(""..player.HatEquiped.Value..""):Clone()
View all 31 lines...

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?

1 answer

Log in to vote
0
Answered by 9 years ago

Insufficient. Show me the hierarchy and tell me the data type.

0
The data type isn't important as it's just there (with no value in it) to show that the hat is part of my game. Scootakip 299 — 9y
0
Also, the hierarchy isn't important either, as this follows the hierarchy perfectly. It just has some issues with FindFirstChild giving errors. Scootakip 299 — 9y
Ad

Answer this question