-- LocalScript placed in StarterPlayer > StarterPlayerScripts (or StarterGui for
GUI)
-- This creates a simple GUI button that, when clicked, triggers one of 5 random
effects!
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local SoundService = game:GetService("SoundService")
local Lighting = game:GetService("Lighting")
local player = [Link]
local playerGui = player:WaitForChild("PlayerGui")
-- Create the GUI
local screenGui = [Link]("ScreenGui")
[Link] = "RandomButtonGui"
[Link] = playerGui
local button = [Link]("TextButton")
[Link] = "RandomButton"
[Link] = [Link](0, 200, 0, 50)
[Link] = [Link](0.5, -100, 0.5, -25) -- Center screen
button.BackgroundColor3 = [Link](255, 100, 100)
[Link] = "Click for Random Chaos!"
button.TextColor3 = [Link](255, 255, 255)
[Link] = true
[Link] = [Link]
[Link] = screenGui
-- Tween the button for fun (pulse effect)
local tweenInfo = [Link](1, [Link],
[Link], -1, true)
local buttonTween = TweenService:Create(button, tweenInfo, {BackgroundColor3 =
[Link](200, 50, 50)})
buttonTween:Play()
-- Function to trigger random thing
local function onButtonClick()
local randomAction = [Link](1, 5) -- Pick 1-5 randomly
if randomAction == 1 then
-- Random color change for the player's character
if [Link] and [Link]:FindFirstChild("HumanoidRootPart")
then
local randomColor = [Link]([Link](0, 255), [Link](0,
255), [Link](0, 255))
for _, part in pairs([Link]:GetChildren()) do
if part:IsA("BasePart") and [Link] ~= "HumanoidRootPart" then
[Link] = randomColor
end
end
print("Action 1: Player turned rainbow!")
end
elseif randomAction == 2 then
-- Flash the screen (tint lighting)
local originalTint = Lighting.ColorShift_Top
local flashTween = TweenService:Create(Lighting, [Link](0.5,
[Link]), {ColorShift_Top = [Link](255, 0, 0)})
flashTween:Play()
[Link]:Connect(function()
TweenService:Create(Lighting, [Link](0.5,
[Link]), {ColorShift_Top = originalTint}):Play()
end)
print("Action 2: Screen flashed red!")
elseif randomAction == 3 then
-- Play a random Roblox sound (assuming default sounds exist)
local sounds = {"rbxasset://sounds/[Link]",
"rbxasset://sounds/[Link]", "rbxasset://sounds/impact_water.mp3"}
local randomSound = [Link]("Sound")
[Link] = sounds[[Link](1, #sounds)]
[Link] = 0.5
[Link] = SoundService
randomSound:Play()
[Link]:Connect(function() randomSound:Destroy() end)
print("Action 3: Random sound played!")
elseif randomAction == 4 then
-- Boost walkspeed temporarily
if [Link] and [Link]:FindFirstChild("Humanoid") then
local humanoid = [Link]
local originalSpeed = [Link]
[Link] = 100
wait(2)
[Link] = originalSpeed
print("Action 4: Super speed burst!")
end
else -- randomAction == 5
-- Spawn a random part in workspace (exploding confetti-like)
local confetti = [Link]("Part")
[Link] = "RandomConfetti"
[Link] = [Link](1, 1, 1)
[Link] = [Link] +
[Link]([Link](-10, 10), 10, [Link](-10, 10))
[Link] = [Link]()
[Link] = [Link]
[Link] = workspace
local bodyVel = [Link]("BodyVelocity")
[Link] = [Link](4000, 4000, 4000)
[Link] = [Link]([Link](-50, 50), [Link](20, 50),
[Link](-50, 50))
[Link] = confetti
game:GetService("Debris"):AddItem(confetti, 3)
print("Action 5: Confetti explosion!")
end
-- Visual feedback on button
local clickTween = TweenService:Create(button, [Link](0.1,
[Link]), {Size = [Link](0, 180, 0, 45)})
clickTween:Play()
[Link]:Connect(function()
TweenService:Create(button, [Link](0.1, [Link]),
{Size = [Link](0, 200, 0, 50)}):Play()
end)
end
-- Connect the click event
button.MouseButton1Click:Connect(onButtonClick)
print("Random Button GUI loaded! Click away for surprises.")