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

I need help with my game?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I'm making an rpg game, and someone gave me a script to use for the armour door, when you touch it if you are a high enough level it is supposed to let you through, but the script is not working and it is not letting me through. 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

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("Level") 
if sp == nil then return false end 
if (sp.Value >= 1) then ----- Change that bit to the level
print("Human passed test")
Door.Transparency = .5
Door.CanCollide = false
wait(3)
Door.CanCollide = true
Door.Transparency = 0
else human.Health= 100
end
end

end

connection = Door.Touched:connect(onTouched)

1 answer

Log in to vote
0
Answered by 10 years ago

all I see is that the last line should read Door:connect(onTouched)

Ad

Answer this question