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

Smooth Closing & Opening Door Issue, please take a read if there are miscoding?

Asked by 8 years ago
Edited 8 years ago

(closing script)

door = script.Parent.Parent.Door
function onClicked()
if door.open.Value == true then
door.open.Value = false
door.CanCollide = true
wait(0.01)
door.Transparency = 1
wait(0.01)
door.Transparency = 0.9
wait(0.01)
door.Transparency = 0.8
wait(0.01)
door.Transparency = 0.7
wait(0.01)
door.Transparency = 0.6
wait(0.01)
door.Transparency = 0.5
wait(0.01)
door.Transparency = 0.4
wait(0.01)
door.Transparency = 0.3
wait(0.01)
door.Transparency = 0.2
wait(0.01)
door.Transparency = 0.1
wait(0.01)
door.Transparency = 0
wait(0.01)
end
end
script.Parent.ClickDetector.MouseClick:connect (onClicked)

(opening door)

door = script.Parent.Parent.Door
function onClicked()
if door.open.Value == false then
door.open.Value = true
door.CanCollide = false
wait(0.01)
door.Transparency = 0
wait(0.01)
door.Transparency = 0.1
wait(0.01)
door.Transparency = 0.2
wait(0.01)
door.Transparency = 0.3
wait(0.01)
door.Transparency = 0.4
wait(0.01)
door.Transparency = 0.5
wait(0.01)
door.Transparency = 0.6
wait(0.01)
door.Transparency = 0.7
wait(0.01)
door.Transparency = 0.8
wait(0.01)
door.Transparency = 0.9
wait(0.01)
door.Transparency = 1
wait(0.01)
end
end
script.Parent.ClickDetector.MouseClick:connect (onClicked)

<Now, I have combined both script into Group ID restriction Door>

local config = script.Parent.Configuration

script.Parent.Touched:connect(function(part)
    if part.Parent and Game:GetService('Players'):GetPlayerFromCharacter(part.Parent) then
        local player = Game:GetService('Players'):GetPlayerFromCharacter(part.Parent)
        if player:GetRankInGroup(config.GroupId.Value) >= config.RankId.Value then
            script.Parent.Transparency = 0.1
            wait(0.01)
            script.Parent.Transparency = 0.2
            wait(0.01)
            script.Parent.Transparency = 0.3
            wait(0.01)
            script.Parent.Transparency = 0.4
            wait(0.01)
            script.Parent.Transparency = 0.5
            wait(0.01)
            script.Parent.Transparency = 0.6
            wait(0.01)
            script.Parent.Transparency = 0.7
            wait(0.01)
            script.Parent.Transparency = 0.8
            wait(0.01)
            script.Parent.Transparency = 0.9
            wait(0.01)
            script.Parent.Transparency = 1
            wait(0.01)
            script.Parent.CanCollide = false
            wait(1)
            script.Parent.Transparency = 0.9
            wait(0.01)
            script.Parent.Transparency = 0.8
            wait(0.01)
            script.Parent.Transparency = 0.7
            wait(0.01)
            script.Parent.Transparency = 0.6
            wait(0.01)
            script.Parent.Transparency = 0.5
            wait(0.01)
            script.Parent.Transparency = 0.4
            wait(0.01)
            script.Parent.Transparency = 0.3
            wait(0.01)
            script.Parent.Transparency = 0.2
            wait(0.01)
            script.Parent.Transparency = 0.1
            wait(0.01)
            script.Parent.Transparency = 0
            wait(0.01)
            script.Parent.CanCollide = true
        end
    end
end)

When I walked in and door opens and closes with some transparency was buffering but not smooth? Please help.

1
Use a loop for changing transparencies. StoIid 364 — 8y

1 answer

Log in to vote
1
Answered by
ferano 0
8 years ago

Use in pairs, it would run much smoother and be far less lines, here is the wiki: http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions&redirect=no#pairs

0
You got me confused, can you explain more? Stanleyloganlego 10 — 8y
Ad

Answer this question