i am making a door that opens when leaderstats are a certain number, but i also want the door to remove itself after used, so i changed a small part of the code to be line 10, but now the door doesnt work anymore
local Exp = 1 local db = true script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Exp.Value >= Exp then if db then db = false script.parent:remove end end end end)
how do i fix this?
I see loads of mistakes on your code. Most of everything you put is deprecated. So lemme change some things. I'll put in --comments
to show you the mistakes.
local Exp = 1 local db = true script.Parent.Touched:Connect(function(hit) --connect is deprecated. Use Connect. if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Exp.Value >= Exp then if db then db = false script.parent:Destroy() --remove() is also deprecated. You didn't put the brackets on remove(). end end end end)
If this doesn't work, let me know and I can re-edit the script.