MapLib
This page contains all the common and beginner scripting methods with appropriate examples when necessary.
Properties
map
This item is read only and cannot be modified. Read OnlyMapLib.map:
Model
This is the map model.
RoundEnding
MapLib.RoundEnding:
RBXScriptSignal
A RBXScriptSignal
that is fired when a map ends.
Example:
MapLib.RoundEnding:Connect(function()
MapLib:Alert("The round has ended", Color3.new(0, 255, 0), 2.5)
end)
Functions
Alert
This method can be used to send an alert, these alerts can be customized by color and duration.
Example:
MapLib:Alert("Hello world!", Color3.new(255, 255, 255), 3)
-- Creates an alert with the given message with the color white and the duration of 3 seconds.
tip
You can pass the color argument as string and it'll still work, just make sure to use a common color name!
MapLib:Alert("Hello world!", "red", 3)
ChangeMusic
MapLib:
ChangeMusic
(
musicId:
number
,
volume:
number?
,
startTick:
number?
) →
(
)
This method can be used to change the current music playing in a map, this also replicates to people spectating.
Example:
MapLib:ChangeMusic(12245541717, 1, 5)
-- Changes the currently playing music to volume 1 and starts at 5 seconds in.
GetButtonEvent
This item only works when running on the server. ServerMapLib:
GetButtonEvent
(
buttonId:
number
|
string
) →
any
This method can be used to run functions once a specific button has been pressed.
Example:
MapLib:GetButtonEvent(5):Connect(function(player: Player?)
MapLib:Alert("Button 5 was pressed!", Color3.fromRGB(255, 255, 255), 4)
end)
note
The player
argument here is the player that pressed the button or nil if the button was activated automatically.
tip
Path buttons work the same as normal buttons, you just need to give a valid button ID in quotation marks (e.g. "6A")
Example:
MapLib:GetButtonEvent("6A"):Connect(function(player: Player?)
MapLib:Alert("Button 6A was pressed!", Color3.fromRGB(255, 0, 0), 5)
end)
Survive
This item only works when running on the server. ServerThis method can be used to make a player survive the round without touching the ExitRegion.
Example:
local Players = game:GetService("Players")
local MapLib = game.GetMapLib:Invoke()()
script.Parent.Touched:Connect(function(other)
local player = Players:GetPlayerFromCharacter(other.Parent)
if player then
MapLib:Survive(player)
end
end)
SetLiquidType
This method can be used to change the state of a liquid. There are 3 default types you can choose, these are water
, acid
and lava
.
Example:
MapLib:SetLiquidType(map.Liquid1, "lava")
-- Changes the liquidType of map.Liquid1 to lava.
tip
You can make your own liquid type in your map's Settings.Liquids
folder. For example a custom liquid type named "bromine" will have the usage:
MapLib:SetLiquidType(map.LiquidWater, "bromine")
Move
Used to move PVInstances
.
Example:
MapLib:Move(map.MovingPart1, Vector3.new(12, 0, 0), 3)
-- Moves map.MovingPart1 along the X axis 12 studs and finishes moving after 3 seconds
MoveRelative
Used to move PVInstances
.
Example:
MapLib:MoveRelative(map.MovingPart2, Vector3.new(12, 0, 0), 5)
--- Moves map.MovingPart2 relative to its rotation.
GetPlayers
This method returns a table containing players currently in a map.
GetFeature
MapLib:
GetFeature
(
name:
string
) →
(
)
This method is used to get any features listed in the features list.