# This script changes the color of a cube when a button is pressed. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Verse.org/Native } using { /UnrealEngine.com/Temporary/Diagnostics } # We define a new script type. # This is like a blueprint for our code. color_changer_script := class(creative_device): # These are our "dials" or connections. # We connect them in the editor later. @editable MyButton : button_device = button_device{} @editable MyCube : prop_manipulator_device = prop_manipulator_device{} # This is the function that runs when the game starts. OnBegin() : void = # We wait for the button to be pressed. # This is called an "Event." loop: # Await fires every time someone presses the button. MyButton.InteractedWithEvent.Await() # Here is the magic line! # We change the material parameter. # "BaseColor" is the name we made in Step 1. # We set it to Blue (0, 0, 1). # note: Verse exposes vector color as separate R/G/B float parameters; # pass each channel individually to the matching scalar or vector slot # on the customizable_static_mesh_device using SetMaterialVectorParameterValue. MyCube.Enable() # Optional: Print a message to help us debug. Print("Color changed to Blue!")