Source Code
BoatScript
-- VARIABLES --
local Boat = script.Parent
local Seat = nil -- Boat.VehicleSeat
local BoatAngular = nil -- Seat.AngularVelocity
local BoatLinear = nil -- Seat.LinearVelocity
local BoatSpeed = 50
-- FUNCTIONS --
function SteerChanged()
BoatAngular.AngularVelocity = Vector3.new(0, -1 * Seat.Steer, 0)
end
function ThrottleChanged()
BoatLinear.LineVelocity = BoatSpeed * Seat.Throttle
end
-- EVENTS --
Seat:GetPropertyChangedSignal("Steer"):Connect(SteerChanged)
Seat:GetPropertyChangedSignal("Throttle"):Connect(ThrottleChanged)
TrashScript
-- SERVICES --
local Players = game:GetService("Players")
-- VARIABLES --
local Boat = script.Parent
local Seat = nil -- Boat.VehicleSeat
local Root = nil -- Boat.RootPart
-- FUNCTIONS --
function RootTouched(TouchedPart)
if TouchedPart.Name == "Trash" then
TouchedPart:Destroy()
end
end
-- EVENTS --
Root.Touched:Connect(RootTouched)
GuiScript
-- VARIABLES --
local TrashFolder = nil -- game.Workspace.Trash
local ScreenGui = script.Parent
local TrashLabel = nil -- ScreenGui.TrashLabel
local CompleteLabel = nil -- ScreenGui.CompleteLabel
local TrashChildren = TrashFolder:GetChildren()
local TotalTrash = #TrashChildren
-- FUNCTIONS --
TrashLabel.Text = "Total Trash : " .. TotalTrash
function UpdateTotalTrash()
local CurrentTrashChildren = TrashFolder:GetChildren()
local CurrentTotalTrash = #CurrentTrashChildren
TrashLabel.Text = "Total Trash : " .. CurrentTotalTrash
if CurrentTotalTrash <= 0 then
CompleteLabel.Visible = true
CompleteLabel:TweenPosition(
UDim2.fromScale(0.5, 0.5),
Enum.EasingDirection.Out,
Enum.EasingStyle.Back,
0.5,
true
)
end
end
-- EVENTS --
TrashFolder.ChildRemoved:Connect(UpdateTotalTrash)
Starter Project
Roblox - Sea Cleaning Simulator Starter Project.rbxl (359.3 KB)