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

GUI control from model?

Asked by 7 years ago
Edited 7 years ago

I would like to make a plane co-pilot system (w/GUI). However, I do not know how to find models within a plane without addressing game.Workspace.etc...

In the Free Modelled aircraft, they have a GUI script which links to a variable I do not understand. Here is the script.

kit = script.Parent.Parent.Parent
flaps = kit.FLAPS
flaps_flex = flaps.FLAPS_FLEX
flaps_straight = flaps.FLAPS_STRAIGHT
gears = kit.GEAR_WHEELS
gears_flex = gears.GEAR_FLEX
gears_straight = gears.GEAR_STRAIGHT
wings = kit.WINGS

function giveTool(weldchild)
    local findhuman = weldchild.Part1.Parent:FindFirstChild("Humanoid")
    if (findhuman ~= nil) then
        player = game.Players:GetPlayerFromCharacter(findhuman.Parent)
        if (player ~=nil) then
            gui = script.Parent["System"]:Clone() -- Change toolname to what tool you want to be given
            gui.Parent = player.PlayerGui
            gui.Seat.Value = script.Parent
            gui.Menu.Flaps.FLAPS_AUTO.Disabled = false
            gui.Menu.Gear.GEAR_AUTO.Disabled = false
            gui.Menu.Ignition.IGNITION.Disabled = false
            gui.Menu.Reverse_Thrusters.REVERSE_SPOILERS.Disabled = false
            if gears.Value.Value == true then
                gui.Menu.Gear.Confirm.BackgroundColor3 = Color3.new(0, 255, 0)
            else
                gui.Menu.Gear.Confirm.BackgroundColor3 = Color3.new(255, 0, 0)
            end
            if flaps.Value.Value == true then
                gui.Menu.Flaps.Confirm.BackgroundColor3 = Color3.new(0, 255, 0)
            else
                gui.Menu.Flaps.Confirm.BackgroundColor3 = Color3.new(255, 0, 0)
            end
        end
    end
end

function removeTool()
    if (gui ~= nil) then
        gui:Remove()
    end
end

script.Parent.ChildAdded:connect(giveTool)
script.Parent.ChildRemoved:connect(removeTool)

--AUTO

function autoSwitchFlaps()
    if flaps.Value.Value == true then
        if wings.Value.Value == true then
            local c = flaps_flex:GetChildren()
            local d = flaps_straight:GetChildren()
            for i = 1, #c do
                c[i].Transparency = 0
            end
            for i = 1, #d do
                d[i].Transparency = 1
            end
        elseif wings.Value.Value == false then
            local c = flaps_flex:GetChildren()
            local d = flaps_straight:GetChildren()
            for i = 1, #c do
                c[i].Transparency = 1
            end
            for i = 1, #d do
                d[i].Transparency = 0
            end
        end
    end
end

function autoSwitchGear()
    if gears.Value.Value == true then
        if wings.Value.Value == true then
            local c = gears_flex:GetChildren()
            local d = gears_straight:GetChildren()
            for i = 1, #c do
                c[i].Transparency = 0
            end
            for i = 1, #d do
                d[i].Transparency = 1
            end
        elseif wings.Value.Value == false then
            local c = gears_flex:GetChildren()
            local d = gears_straight:GetChildren()
            for i = 1, #c do
                c[i].Transparency = 1
            end
            for i = 1, #d do
                d[i].Transparency = 0
            end
        end
    end
end

wings.Value.Changed:connect(autoSwitchFlaps)
wings.Value.Changed:connect(autoSwitchGear)

Any help appreciated.

0
Add more context. You're not asking for any scripting help. RubenKan 3615 — 7y
0
Happy now? RobskiT 5 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

is the plane "kit" or is "kit" a child model inside the plane? if it's just a child parented to the actual plane then you can do

kit.Parent

however if the kit is the actual plane then just do "kit"

0
Thanks! RobskiT 5 — 7y
Ad

Answer this question