o1-preview-2024-09-12· OpenAI
WildChat-4.8M (AI2)
Generate an advanced roblox script where the player grows bigger every second.
- User
Generate an advanced roblox script where the player grows bigger every second.
- Assistant
Generate an advanced roblox script where the player grows bigger every second.
Here's an advanced Roblox script that makes the player's character grow bigger every second. This script handles edge cases, supports both R15 and R6 avatars, and includes comments for clarity.
Instructions:
ServerScriptService as a Script (not a LocalScript).--[[
Script: GrowCharacterOverTime.lua
Description: Makes the player's character grow bigger every second.
Author: [Your Name]
Date: [Date]
]]
-- Services
local Players = game:GetService("Players")
-- Configuration
local GROWTH_INTERVAL = 1 -- Time in seconds between each growth
local GROWTH_FACTOR = 1.01 -- Scale multiplier applied each interval (1% growth)
-- Function to scale the character
local function scaleCharacter(character, scaleFactor)
-- Check for humanoid
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then
warn("Humanoid not found in character:", character.Name)
return
end
-- For R15 avatars
if humanoid.RigType == Enum.HumanoidRigType.R15 then
local scales = {
"BodyHeightScale",
"BodyWidthScale",
"BodyDepthScale",
"HeadScale",
"BodyProportionScale",
"BodyTypeScale",
}
for _, scaleName in ipairs(scales) do
local scaleValue = humanoid:FindFirstChild(scaleName)
if scaleValue and scaleValue:IsA("NumberValue") then
scaleValue.Value *= scaleFactor
else
-- Create scale values if they don't exist
scaleValue = Instance.new("NumberValue")
scaleValue.Name = scaleName
scaleValue.Value = scaleFactor
scaleValue.Parent = humanoid
end
end
else
-- For R6 avatars, manually scale each part
for _, part in ipairs(character:GetChildren()) do
if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
part.Size *= scaleFactor
-- Optional: Adjust position to prevent sinking into the ground
part.Position += Vector3.new(0, (part.Size.Y * (scaleFactor - 1)) / 2, 0)
end
end
end
end
-- Handle character when it's added
local function onCharacterAdded(character)
-- Start a coroutine to continuously scale the character
coroutine.wrap(function()
-- Wait to ensure the character is fully loaded
local humanoid = character:WaitForChild("Humanoid")
while character.Parent and humanoid.Health > 0 do
scaleCharacter(character, GROWTH_FACTOR)
wait(GROWTH_INTERVAL)
end
end)()
end
-- Handle player when they join
local function onPlayerAdded(player)
-- Connect character added event
player.CharacterAdded:Connect(onCharacterAdded)
end
-- Connect player added event
Players.PlayerAdded:Connect(onPlayerAdded)
-- For players who are already in the game (if the script is added during runtime)
for _, player in ipairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Explanation:
Players service to handle player events.GROWTH_INTERVAL: Time between each growth step (in seconds).GROWTH_FACTOR: The factor by which the character scales each interval.Humanoid.BodyHeightScale, BodyWidthScale, etc.).HumanoidRootPart.GROWTH_INTERVAL seconds.CharacterAdded event to handle characters that spawn after the player joins.onPlayerAdded to Players.PlayerAdded to handle future players.Notes:
Customization:
GROWTH_INTERVAL and GROWTH_FACTOR in the configuration section to change how quickly and by how much the character grows.Disclaimer:
Not yet included in a published release.