ScriptAPI source

Working Examples

Browse practical scripts for interaction, triggers, dialogs, players, character physics, media, lights, materials, audio, animation, spritesheets, spawning, sitpoints, script events, and chat commands. Code blocks are loaded from the raw .cs files in this folder.

ScriptAPI / Examples

Example Index

These examples are given to show acceptable patterns for user-uploaded scripts on the TestPlatform5 platform. The current script API is the very first version, and alot more system object types and features will be added soon. If you are searching for something specific, use the filter search box below to narrow the examples list shown below.

Dialogs / Callbacks

DialogDemo

Shows success and error dialogs, including an OK/Cancel result callback.

Raw .cs
Loading DialogDemo.cs...

Dialogs / Target Users

TargetedDialogCallback

Targets a dialog at a named user and handles the selected button result.

Raw .cs
Loading TargetedDialogCallback.cs...

Interaction / Self Object

InteractableSelf

Makes the script object clickable and shows a dialog when a user interacts with it.

Raw .cs
Loading InteractableSelf.cs...

Objects / SceneObject

SceneObjectReference

Uses a SceneObject field, hides its renderer, and reports the target id.

Raw .cs
Loading SceneObjectReference.cs...

Objects / Per-User Visibility

RendererVisibleForUser

Makes a slotted button interactable and toggles a target renderer independently for each user. Private visibility resets when the user rejoins.

Raw .cs
Loading RendererVisibleForUser.cs...

Objects / Smooth Moving Lights

LightControlLerp

Runs multi-light dance patterns with timed rotation waypoints. The server sends only a modest number of commands while each client and the shared instance interpolate smoothly between them.

Raw .cs
Loading LightControlLerp.cs...

Objects / Directional Lights

DirectionalLightSwitch

Uses a slotted button to switch a directional light on and off, then sends the current shared light state to joining users.

Raw .cs
Loading DirectionalLightSwitch.cs...

Materials / Emission Lists

MaterialEmissionListDemo

A glow switch: click a button and the chosen objects (with everything inside them) fade into a glow, click again and they fade out. Pick the colour, strength and fade time in the Inspector; optionally a colour per object. Uses SetObjectGlow / ClearObjectGlow.

Raw .cs
Loading MaterialEmissionListDemo.cs...

Media / URL

MediaScreenUrl

Registers a click target and changes a media screen URL for one screen id or all screens.

Raw .cs
Loading MediaScreenUrl.cs...

Media / Per-User URL

PrivateMediaScreenChat

Adds a /privatevideo <url> or /privatevideo <screenId> <url> chat command that changes what the media screens show for the player who typed it only (/yt is the built-in command that changes them for everybody). The command name can be changed in the Inspector.

Raw .cs
Loading PrivateMediaScreenChat.cs...

Players / Emotes

PlayerEmoteControl

Toggles an emote on the person who clicks, everyone, or a named user. Pick the emote in the selectedEmote dropdown in the Inspector: it lists your own emotes, uploaded or bought in the Avatar Editor.

Raw .cs
Loading PlayerEmoteControl.cs...

Players / Avatar Clones

AvatarCloneControl

Spawns a server avatar clone by username (in one of their outfits by name, or the one they wear), toggles the emote picked in its selectedEmote dropdown, drops it as a ragdoll and stands it back up, slots it into a sitpoint, and destroys it through the cached clone reference.

Raw .cs
Loading AvatarCloneControl.cs...

Players / Scale

PlayerScale

Interactable that toggles scale for the clicking user, everyone, or a named target.

Raw .cs
Loading PlayerScale.cs...

Players / Character Physics

CharacterPhysicsModes

Player ragdolls: a Drop button (with an optional push) and fall trigger zones turn the player into a ragdoll that falls onto whatever is below; a Stand button and recover timers get them up again. Ragdoll strength, gravity, drag, friction and bounce are set in the Inspector. Optional audio object slots.

Raw .cs
Loading CharacterPhysicsModes.cs...

Users / Lifecycle

UserJoinPart

Overrides user join and part callbacks for simple presence logging.

Raw .cs
Loading UserJoinPart.cs...

Users / Enumeration

ForEachUser

Runs a repeating coroutine that logs active users through ForEachUser.

Raw .cs
Loading ForEachUser.cs...

Script Events / Sender

PostScriptEventsSender

Posts global and grouped script events with structured name/value data.

Raw .cs
Loading PostScriptEventsSender.cs...

Script Events / Receiver

PostScriptEventsReceiver

Listens to global and grouped script events and reads typed payload values.

Raw .cs
Loading PostScriptEventsReceiver.cs...

Chat / Slash Commands

ChatCommandRouter

Listens for a custom slash command, reads the sender and arguments, and adds a [Script] chat response.

Raw .cs
Loading ChatCommandRouter.cs...

Triggers / Self Object

TriggerSelf

Registers enter and exit callbacks on the script object.

Raw .cs
Loading TriggerSelf.cs...

Triggers / Target Object

TriggerSceneObjectSlot

Registers enter and exit callbacks on a SceneObject trigger slot.

Raw .cs
Loading TriggerSceneObjectSlot.cs...

Triggers / Audio

NamedTriggerSoundOnce

Plays a target audio source when a matching object enters a trigger, with name filtering and cooldown.

Raw .cs
Loading NamedTriggerSoundOnce.cs...

Triggers / Reset

ResetTrigger

Resets players with TeleportPlayer and dynamic rigidbodies with transform client commands.

Raw .cs
Loading ResetTrigger.cs...

Audio / Collisions

CollisionVelocitySound

Plays an impact sound when objects bump into each other, higher the faster they meet. Put it on a moving physics object, or on a still object (a wall, a bell) that physics objects hit. Hits on objects whose name contains a word you choose can play a different sound. Uses RegisterCollision.

Raw .cs
Loading CollisionVelocitySound.cs...

Animation / Legacy Control

Rollercoaster1

Controls a legacy Animation with synced random frame, play, stop, and reset (back to frame 0) interactions. Up to two cart sounds (objects with an Audio Source inside the carts) are pitched by how fast their cart moves with SetAudioPitchByMotion: silent and low when the ride stands still, higher the faster it goes.

Raw .cs
Loading Rollercoaster1.cs...

Spritesheets / Hints

Spritesheet

Variant of the spritesheet button example with interaction hint text.

Raw .cs
Loading Spritesheet.cs...

Inventory / Spawning

InventorySpawner

Spawns an inventory item from a click target, caps total spawned objects, and despawns after a timeout.

Raw .cs
Loading InventorySpawner.cs...

Inventory / Backpack

Backpack

A sandbox backpack: a Backpack button on every player's control bar opens a panel of your items (icon and name each); picking one spawns it in front of that player. Per-player limit, optional auto destroy, items removed when their player leaves. Meshes and prefabs work, including rigidbodies and scripts on them.

Raw .cs
Loading Backpack.cs...

Sitpoints / Occupancy

SitpointDetection

Responds to user sit and stand events for a watched sitpoint.

Raw .cs
Loading SitpointDetection.cs...

Sitpoints / Input

SitpointVehiclePrototype

Registers sitpoint input and applies movement forces to build a prototype vehicle controller.

Raw .cs
Loading SitpointVehiclePrototype.cs...