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

Am i Makeing This Door Script Correctly?

Was wondering if I need to change anything or is it perfect? its for a rpg game

Here is the script:

function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end end

lvl = script.Parent.Parent.DoorSettings.Lvl.Value time = script.Parent.Parent.DoorSettings.OpenTime.Value

Door = script.Parent function onTouched(hit) print("Door Hit") local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil ) then

		print("Human touched door")

		local player = getPlayer(human) 

if (player == nil) then return end local stats = player:findFirstChild("leaderstats") local sp = stats:findFirstChild("Lvl") if sp == nil then return false end if (sp.Value >= lvl) then print("Human passed test") Door.Transparency = 1 Door.CanCollide = false wait(time) Door.CanCollide = true Door.Transparency = 0.5 else human.Health = human.Health end end

end

connection = Door.Touched:connect(onTouched)

2 answers

Is there a weld on the door?

5 comments

0

That's not an answer xD

0

its a door level requirement script to go threw the door

0

that is confusing

0

So is there supposed to be an opening animation?

0

You can just use a simple weld.

Try using that:

function getPlayer(humanoid) 
local players = game.Players:GetChildren() 
for i = 1, #players do 
if players[i].Character.Name == humanoid.Name then 
return players[i] 
end 
end 
end

local lvl = script.Parent.Parent.DoorSettings.Lvl.Value 
local time = script.Parent.Parent.DoorSettings.OpenTime.Value

Door = script.Parent
function onTouched(hit) 
print("Door Hit") 
local human = hit.Parent:findFirstChild("Humanoid") 
if (human ~= nil ) then
print("Human touched door")
local player = getPlayer(human)
if (player == nil) then 
return 0 -- For sure
end
local stats = player:findFirstChild("leaderstats") 
local sp = stats:findFirstChild("Lvl") 
if sp == nil then 
return 0  -- For sure
end 
if (sp.Value >= lvl) then 
print("Human passed test") 
Door.Transparency = 1 
Door.CanCollide = false 
wait(time) 
Door.CanCollide = true 
Door.Transparency = 0.5 
end 
end

end

connection = Door.Touched:connect(onTouched)

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