Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My Level 25 only door won't work because of a problem. The problem is W001: Unknown global 'hit'?

My Level 25 only door won't work because of a problem. The problem is W001: Unknown global 'hit' Script:

local required_level = 25

local db = true script.Parent.Touched:Connect(function() if hit.Parent:FindFirstChild("Humanoid") then -- this line is the one that has the problem W001: Unknown global 'hit' local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Level.Value >= required_level then if db then db = false script.Parent.Transparency = 0.5 script.Parent.CanCollide = false wait(3) script.Parent.CanCollide = true script.Parent.Transparency = 0 db = true end else player.Character.Humanoid.Health = 0 end end end)

3 comments

0

Please use a Lua Text Box, When you edit the post,where it has the Lua icon, click that then put all of your code for that one script inside of those to bars that show up. Start to finish, you can have multiple boxes as well.

0

Please use a Lua Text Box, When you edit the post,where it has the Lua icon, click that then put all of your code for that one script inside of those to bars that show up. Start to finish, you can have multiple boxes as well.

0

Please use a Lua Text Box, When you edit the post,where it has the Lua icon, click that then put all of your code for that one script inside of those to bars that show up. Start to finish, you can have multiple boxes as well.

1 answer

You forgot to add "hit" inside the function: just replace this line

script.Parent.Touched:Connect(function(hit)

This discussion is preserved as it was. New answers, comments, and votes are closed.