#New Ship, Same Function

2 messages · Page 1 of 1 (latest)

signal wyvern
#

right now I have a Ship that has:
Ship(Model)
>Seat
>Script
```lua
local seat = script.Parent -- Assuming the script is placed in the Seat object
local ship = seat.Parent -- Assuming the Seat is a child of the ship model
local engine = ship.Engine
local isSitting = script.Parent.isSitting

local boolValue = workspace.Ship.Engine.isStarting -- Replace "BoolValue" with the path to your BoolValue object

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if seat.Occupant then
isSitting.Value = true
else
isSitting.Value = false
end
end)
>isSitting(BoolValue) >Engine(Model) >Script lua
local RS = game.ReplicatedStorage
local value = script.Parent.isStarting

RS.EngineOn.OnServerEvent:Connect(function(player)
script.Parent.isStarting.Value = true
end)

RS.EngineOff.OnServerEvent:Connect(function(player)
script.Parent.isStarting.Value = false
end)

value:GetPropertyChangedSignal("Value"):Connect(function()
if value.Value then
print("EngineStarted")
else
print("EngineStopped")
end
end)
```
>isStarting(BoolValue)
>Part

#

A script in ServerScriptService that relates to the Ship's flight function

local ship = game.Workspace.Ship
local boolValue = game.Workspace.Ship.Engine.isStarting

local function AnchoredOFF()
    for i,v in pairs (ship:GetChildren()) do
        if v:IsA("BasePart") or v:IsA("MeshPart") then
            v.Anchored = false
        end
    end
end

local function AnchoredON()
    for i,v in pairs (ship:GetChildren()) do
        if v:IsA("BasePart") or v:IsA("MeshPart") then
            v.Anchored = true
        end
    end
end

boolValue:GetPropertyChangedSignal("Value"):Connect(function()
    while boolValue.Value and not AnchoredON() do
        AnchoredON()
        for i = 1, 200 do
            ship:PivotTo(ship:GetPivot() + Vector3.new(0,.1,0))
            wait()
        end
        while not boolValue.Value and AnchoredOFF() do
            AnchoredOFF()
        end
    end
end)