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

I'm Experiencing Problems with Transparency Script?

Asked by 4 years ago

Hey.. I'm sort of a new scripter when it comes to lua, and my friend and I are trying to make a game (pretty obvious). In the game, "people", which are made up of parts, move around using transparency. I have one script that controls values that are sensed, which then makes a part visible, and 2 scripts that make the part visible, and invisible. Since the people are made up of parts and meshes, I can't really have them all in one script, and I can't turn meshes into unions, so I came up with a script that I can just copy and paste into all of the parts in the person. The problem that I am having with the scripts is that in the visible and invisible scripts, they only work once. The first time that I change a value, it turns visible, and then when I change the value again, it turns invisible. BUT, if I change the value again, it won't turn visible again. I changed some stuff around to test it, but I couldn't really find anything that could be causing this? Could someone please help me with what is wrong with my script? The scripts are here:

Visible script:

local a = true

repeat  

    repeat

        wait(0.1)

    until game.Workspace.PValues.PStage.Value == 1

    script.Parent.Transparency = 0
    wait(1)

until a == false

Invisible script:

local a = true

repeat  

    repeat

        wait(0.1)

    until game.Workspace.PValues.PStage.Value == 0

    script.Parent.Transparency = 1
    wait(1)

until a == false

Turn values on and off script:

repeat

    game.Workspace.PValues.PRDoor.Value = 0
    game.Workspace.PValues.PStage.Value = 1
    wait(10)
    game.Workspace.PValues.PLeavingStage.Value = 1
    game.Workspace.PValues.PStage.Value = 0
    wait(15)
    game.Workspace.PValues.PTables.Value = 1
    game.Workspace.PValues.PLeavingStage.Value = 0
    script.Parent.FootSteps.Playing = true
    wait(1.5)
    script.Parent.FootSteps.Playing = true
    wait(20)
    game.Workspace.PValues.PTables.Value = 0
    game.Workspace.PValues.PPartyRoom2.Value = 1
    script.Parent.FootSteps.Playing = true
    wait(1.5)
    script.Parent.FootSteps.Playing = true
    wait(20)
    game.Workspace.PValues.PPartyRoom2.Value = 0
    game.Workspace.PValues.PRHall.Value = 1
    script.Parent.FootSteps.Playing = true
    wait(1.5)
    script.Parent.FootSteps.Playing = true
    wait(10)
    game.Workspace.PValues.PRHall.Value = 0
    game.Workspace.PValues.PPartyRoom1.Value = 1
    wait(20)
    game.Workspace.PValues.PRHall.Value = 1
    game.Workspace.PValues.PPartyRoom1.Value = 0
    wait(10)
    game.Workspace.PValues.PRHall.Value = 0
    game.Workspace.PValues.PRDoor.Value = 1
    script.Parent.FootSteps.Playing = true
    wait(1.5)
    script.Parent.FootSteps.Playing = true
    wait(5)


until game.Workspace.Values.RightDoorValue.Value == 0

Thank you so much for helping out! I hope someone can help me because I don't really know what is wrong ;_; Thanks!

1 answer

Log in to vote
0
Answered by
pingsock 111
4 years ago

Here's my Fade function, I didnt recreate yours like I did others, so you'll have to see this for yourself.

    local Part = Instance.new("Part",workspace)
    Part.Anchored = true
    Part.Position = Vector3.new(0,6,0)

local Transparent = false

function Fade(Type)
    local Transparency = Part.Transparency
    if Type == "Invisible" and Transparent == true then
    while Part.Transparency < 0.05 do
        for i = 0,1,0.05 do
            wait()
            Part.Transparency = Transparency + i
        end
        end
    Part.Transparency = 1
    elseif Type == "Visible" and Transparent == false then
        while Part.Transparency < 0.05 do
            for i = 0,1,0.05 do
                wait()
                Part.Transparency = Transparency - i
            end
            end
        Part.Transparency = 0
    end
end

wait(5)
Fade("Invisible")
wait(5)
Fade("Visible")
0
Ok thank you! I tried messing with the script for a while, but I couldn't really figure out how to get it to change with my value. I figure I could just configure the script to when I want it to change, and just paste it into all of the parts. Thanks! sy1v3on 0 — 4y
0
Another thing you could do it "for i,v in pairs(Model:GetChildren())", I could explain it all, but it's better if you look on the DevForum's examples. pingsock 111 — 4y
Ad

Answer this question