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

Door script Help?

Asked by 10 years ago

ldoor=script.Parent Door=script.Parent function onTouched(hit) for 1,5 do wait(.1) Door.Transparency= +.1 end wait(.5) for i=1, 200 do ldoor.CFrame = ldoor.CFrame * CFrame.new(0,0.4,0) wait(0.025) end wait(5) for i=1, 200 do ldoor.CFrame = ldoor.CFrame * CFrame.new(0,0.4,0) wait(0.025) end for 1,5 do wait(.1) Door.Transparency= -.1 end wait(.5) script.Parent.Touched:connect(onTouched)

Any ideas on how to fix?

0
I think i mucked up the loop slightly Hexcalibur 10 — 10y
0
Please edit your post to use Lua code formatting BlueTaslem 18071 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

Couldn't really read your code but this may be some help.

local Door = script.Parent
local Open = false
local Debounce = false

Door.Touched:connect(function(Hit)
    if Hit and Hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Hit.Parent) then -- Checks to see if the Hit or Object is a Player.
        if Debounce then return end --Checks to see if the Door is already moving.
        Debounce = true
        if Open then -- Checks to see if door is open or not.
            for i = 1, 10 do
                Door.CFrame = Door.CFrame - Vector3.new(0, 0.1, 0) -- Makes the door go back down.
                wait(0.1)
            end
            Open = false
        else
            for i = 1, 10 do
                Door.CFrame = Door.CFrame + Vector3.new(0, 0.1, 0) --Makes the door go up.
                wait(0.1)
            end
            Open = true
        end
        wait(0.1)
        Debounce = false
    end
end)

-- OR THIS ONE

Door.Touched:connect(function(Hit)
    if Hit and Hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Hit.Parnet) then -- Checks to see if the Hit or Object is a Player.
        if Debounce then return end
        Debounce = true
        if Open then
            Door.Transparency = 0
            Door.CanCollide = true
            Open = false
        else
            Door.Transparency = 0.5
            Door.CanCollide = false
            Open = true
        end
        wait(0.1)
        Debounce = false
    end
end)

0
Also you can add the for loop back into that. Tell me if it works or not xImmortalChaos 565 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

** If you'd like a gamepass door, here's this. I am kind of confused on what you needed, a VIP door or normal door.**

-- Recommended: Place this in the door you'd like to use.
----------------------------------------------------------------------- 
PassOrShirtID = (INSERTBADGEID) -- Change this to your asset/shirt/badge/pass ID
Door = script.Parent -- Change this to the door (if needed)
OpenTime = (INSERTTIMEOPENED) -- Change how long you want the door open
Prompt = true -- true = if the player doesn't have the item, prompt a screen to let them buy it. false = kill the player.
-----------------------------------------------------------------------

--Do not touch below--
Serv = game:GetService("BadgeService")
MServ = game:GetService("MarketplaceService")
if not _G.Players then
    _G.Players = {
        [PassOrShirtID] = {};
    }
    print("Players Created")
elseif not _G.Players[PassOrShirtID] then
    _G.Players[PassOrShirtID] = {};
    print("Players.Pass created")
end

Table = _G.Players[PassOrShirtID]

function CheckPlayer(player2)
    for i = 1,#Table do
        if Table[i] == player2 then
            return true
        end
    end
    return false
end

Door.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if Serv:UserHasBadge(player.userId,PassOrShirtID) or CheckPlayer(player) then
            Door.CanCollide = false; Door.Transparency = 0.5;
            wait(OpenTime);
            Door.CanCollide = true; Door.Transparency = 0;
        else
            if Prompt then 
                MServ:PromptPurchase(player,PassOrShirtID)
                h = player.Character:FindFirstChild("Humanoid")
                if h then h.WalkSpeed = 0 end
                local con;
                con = MServ.PromptPurchaseFinished:connect(function(ply,asset,purch)
                    if ply == player and asset == PassOrShirtID then
                        con:disconnect()
                        if purch then
                            if h then h.WalkSpeed = 16 end
                            table.insert(Table,player)
                        else
                            player.Character:BreakJoints()
                        end
                    end 
                end)
            else
                player.Character:BreakJoints()
            end
        end
    end
end)


Answer this question