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

Will this work??

Asked by 10 years ago

I have a script, that requires sufficient credit in order to pass through a door. But it should only charge once:

script.Parent.Touched:connect(function(player) --Door gets touched
    humanoid = player.Parent:FindFirstChild("Humanoid") --If it's the player that touched the door
    if humanoid ~= nil then
        person = game.Players:FindFirstChild(player.Parent.Name)
        touched = script.Parent:FindFirstChild(player.Parent.Name)
        if person ~= nil  and  touched == nil then
            person.leaderstats.Admins.Value = person.leaderstats.Admins.Value - 1 --Decreases the credits
            a = Instance.new("StringValue", script.Parent)
            a.Name = player.Parent.Name
            script.Parent.CanCollide = false
            wait(2)
            script.Parent.CanCollide = true
        elseif touched ~= nil then
            script.Parent.CanCollide = false
            wait(2)
            script.Parent.CanCollide = true
        else humanoid.Health = 0 
        end
    end
end
0
Just test it in game, if it doesn't work, use F9 and look at server console (Output) Tempestatem 884 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

i would use a table to store the people who already paid, or whatever, and after they go through the door, their name or userId is put inside the table so they can never use the door again, if thats what your asking.

Ad

Answer this question