Greetings developers !
As a lot of beginner developers asked me how to properly resize the character scale for their game project, i decided to made a small free ressource pack that may help you to do it in multiple different ways.
This ressource pack include:
- Automaticaly resizing the character using a IntValue.
- Automaticaly resizing the character while touching parts in the workspace.
- Manualy resizing the character using a Gui TextBox and [+] [-] buttons.
- Showing your current size in a Gui text.
- A setting button to enable & disable the automatic character resize.
- Setting up a minimal and maximal character size from -100 to 100.
- Reset the character size to default using a Gui button.
- A smooth character resize using Tween.
- Handle WalkSpeed and Camera changes while resizing.
There is the downloadable file
Ressource.rbxl (47,9 Ko)
Screenshots
Take a look into the scripts
ServerScriptService > Scaling_Handler
Creating a folder and 2 values inside the player, handle remote Server Events, Handle important value changes and more.
local Players_Storage = game:GetService("Players")
local Replicated_Storage = game:GetService("ReplicatedStorage")
local Tween_Service = game:GetService("TweenService")
local TweenInfos = TweenInfo.new(0.25)
local Events_Folder = Replicated_Storage:WaitForChild("Events" ,300)
Players_Storage.PlayerAdded:Connect(function(Player)
---------------------------------------------------------------------------------
local Scale_Folder = Instance.new("Folder")
local Size_Value = Instance.new("IntValue")
local Enabled_Value = Instance.new("BoolValue")
Scale_Folder.Name = "Scaling"
Size_Value.Name = "Size"
Enabled_Value.Name = "Enabled"
Size_Value.Value = 0
Enabled_Value.Value = true
Scale_Folder.Parent = Player
Size_Value.Parent = Scale_Folder
Enabled_Value.Parent = Scale_Folder
---------------------------------------------------------------------------------
Size_Value.Changed:Connect(function()
local Humanoid = Player.Character:WaitForChild("Humanoid" ,10)
local Goal = {}
local Scale_List = {
"BodyHeightScale";
"BodyDepthScale";
"BodyWidthScale";
"HeadScale";
}
for _, Selected in pairs(Scale_List)do
if Humanoid ~= nil and Humanoid:WaitForChild(Selected, 10) and Enabled_Value.Value == true then
if Size_Value.Value > 0 and Size_Value.Value <= 100 then
Goal.Value = 1 + Size_Value.Value/10
local Tween = Tween_Service:Create(Humanoid[Selected], TweenInfos, Goal)
Tween:Play()
Humanoid.WalkSpeed = 16 + Size_Value.Value/7
elseif Size_Value.Value < 0 and Size_Value.Value >= -100 then
Goal.Value = 1 + Size_Value.Value/140
local Tween = Tween_Service:Create(Humanoid[Selected], TweenInfos, Goal)
Tween:Play()
Humanoid.WalkSpeed = 16 - Size_Value.Value/74
elseif Size_Value.Value == 0 then
Goal.Value = 1
local Tween = Tween_Service:Create(Humanoid[Selected], TweenInfos, Goal)
Tween:Play()
Humanoid.WalkSpeed = 16
end
end
end
end)
---------------------------------------------------------------------------------
local Enabled_Event = Events_Folder:WaitForChild("Enabled" ,30)
local Scaling_Event = Events_Folder:WaitForChild("Scaling" ,30)
if Enabled_Event ~= nil and Scaling_Event then
Enabled_Event.OnServerEvent:Connect(function(Local_Player)
if Local_Player == Player and Enabled_Value.Value == true then
Size_Value.Value = 0
Enabled_Value.Value = false
elseif Local_Player == Player and Enabled_Value.Value == false then
Enabled_Value.Value = true
end
end)
end
Scaling_Event.OnServerEvent:Connect(function(Local_Player, Custom_Value)
if Local_Player == Player and Enabled_Value.Value == true then
Size_Value.Value = Custom_Value
end
end)
end)
StarterPlayerScripts > Scaling_Handler
Handle all Gui changes and prompts and fire the required events.
local Players_Storage = game:GetService("Players")
local Replicated_Storage = game:GetService("ReplicatedStorage")
local Workspace_Storage = game:GetService("Workspace")
local Player = Players_Storage.LocalPlayer
local Player_Gui = Player:WaitForChild("PlayerGui" ,300)
local Scale_Folder = Player:WaitForChild("Scaling" ,300)
local Events_Folder = Replicated_Storage:WaitForChild("Events" ,300)
local Scale_Storage = Workspace_Storage:WaitForChild("Scaling" ,300)
if Player_Gui ~= nil and Scale_Folder ~= nil and Events_Folder ~= nil then
local Settings_Gui = Player_Gui:WaitForChild("Settings" ,30)
local Size_Value = Scale_Folder:WaitForChild("Size" ,30)
local Enabled_Value = Scale_Folder:WaitForChild("Enabled" ,30)
local Enabled_Event = Events_Folder:WaitForChild("Enabled" ,30)
local Scaling_Event = Events_Folder:WaitForChild("Scaling" ,30)
if Settings_Gui ~= nil and Size_Value ~= nil and Enabled_Value ~= nil and Enabled_Event ~= nil and Scaling_Event ~= nil then
---------------------------------------------------------------------------------
Settings_Gui.Enabled_Frame.Button.MouseButton1Click:Connect(function()
Enabled_Event:FireServer()
end)
Enabled_Value.Changed:Connect(function()
if Enabled_Value.Value == true then
Settings_Gui.Enabled_Frame.Button.Info.Text = "Enabled"
Settings_Gui.Enabled_Frame.Button.Info.TextColor3 = Color3.new(0.333333, 1, 0)
elseif Enabled_Value.Value == false then
Settings_Gui.Enabled_Frame.Button.Info.Text = "Disabled"
Settings_Gui.Enabled_Frame.Button.Info.TextColor3 = Color3.new(1, 0, 0)
end
end)
---------------------------------------------------------------------------------
local Custom_Value = Instance.new("IntValue")
Custom_Value.Value = 0
Settings_Gui.Custom_Frame.Button.MouseButton1Click:Connect(function()
Custom_Value.Value = Settings_Gui.Custom_Frame.TextBox.Text
Settings_Gui.Custom_Frame.TextBox.Text = ""
Scaling_Event:FireServer(Custom_Value.Value)
end)
Settings_Gui.Custom_Frame.TextBox.FocusLost:Connect(function(EnterPressed)
if EnterPressed then
Custom_Value.Value = Settings_Gui.Custom_Frame.TextBox.Text
Settings_Gui.Custom_Frame.TextBox.Text = ""
Scaling_Event:FireServer(Custom_Value.Value)
end
end)
---------------------------------------------------------------------------------
Settings_Gui.Current_Frame.More.MouseButton1Click:Connect(function()
Scaling_Event:FireServer(Size_Value.Value + 1)
end)
Settings_Gui.Current_Frame.Less.MouseButton1Click:Connect(function()
Scaling_Event:FireServer(Size_Value.Value - 1)
end)
Settings_Gui.Reset.MouseButton1Click:Connect(function()
Scaling_Event:FireServer(0)
end)
Size_Value.Changed:Connect(function()
Settings_Gui.Current_Frame.Info.Text = Size_Value.Value
Player.CameraMaxZoomDistance = 15 + Size_Value.Value
Player.CameraMinZoomDistance = 15 + Size_Value.Value
Player.CameraMaxZoomDistance = 150
Player.CameraMinZoomDistance = 0.5
end)
---------------------------------------------------------------------------------
local More_Part = Scale_Storage:WaitForChild("More" ,30)
local Less_Part = Scale_Storage:WaitForChild("Less" ,30)
local Ready = true
if More_Part ~= nil and Less_Part ~= nil then
More_Part.Touched:Connect(function()
if Ready == true then
Ready = false
Scaling_Event:FireServer(Size_Value.Value + 1)
wait(0.5)
Ready = true
end
end)
Less_Part.Touched:Connect(function()
if Ready == true then
Ready = false
Scaling_Event:FireServer(Size_Value.Value - 1)
wait(0.5)
Ready = true
end
end)
end
end
end
Conclusion
Thank you for reading !
If you got any questions, feedbacks or suggestions, please tell me it !