Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When I click, how do I do the room size increase?

When I hold click, the op-op room size increases but I want it to increase fast, then step by step slower then it ends. How do I do that? Script:

`local replicatedStorage = game:GetService("ReplicatedStorage")
	local remoteEventStorage = replicatedStorage:WaitForChild("RemoteEventStorage")
		local fruitEvents = remoteEventStorage:WaitForChild("FruitEvents")
	local roomFolder = fruitEvents:WaitForChild("Room")
		local roomEvent = roomFolder:WaitForChild("Room")
		local stopEvent = roomFolder:WaitForChild("Finish")
	local modelStorage = replicatedStorage:WaitForChild("ModelStorage")
		local attackFolder = modelStorage:WaitForChild("Room")
			local attackModel = attackFolder:WaitForChild("Room")
			local stopped = false
			local t = 0

stopEvent.OnServerEvent:connect(function()
	stopped = true
	print(stopped)
		wait(t)
	t = 0
	stopped = false
	print(stopped)
end)

roomEvent.OnServerEvent:connect(function(player)
	local character = player.Character or player.CharacterAdded:wait()
	local newModel = attackModel:Clone()
		newModel.Parent = character
		newModel.Room.Position = character.UpperTorso.Position + Vector3.new(0,-9,0)
		newModel.Room.Block.Position = character.UpperTorso.Position + Vector3.new(0,-2,0)
		newModel.Room.Block.Script.Disabled = false
		for i = 6,95 do
			local z = i - 6
			if stopped==false then
			newModel.Room.Size = newModel.Room.Size + Vector3.new(0.2,0.19,0.2)
			newModel.Room.Block.Size = newModel.Room.Block.Size + Vector3.new(0.195,0.010,0.195)
			wait(.01)
			end
			if stopped==true then
				t = z+t 
			end
			print(z)
		end
	game.Debris:AddItem(newModel,10)
end)
`

1 answer

✓ Accepted answer

You could use TweenService to change the size of the room with an easing style of Quint and and easing direction of In.

Here, I am defining some arbitrary size bigger then the room's size but you can adjust it to your own needs. In order to implement this you could do something like this:

local TweenService = game:GetService("TweenService")
local goal = {}
goal.Size = newModel.Room.Size + Vector3.new(50 , 50 , 50)
local info = TweenInfo.new(4 , Enum.EasingStyle.Quint , Enum.EasingDirection.Out)
local tween = TweenService:Create(newModel.Room , info , goal)
local goal2 = {}
goal.Size = newModel.Room.Block.Size + Vector3.new(50 , 50 , 50)
local tween2 = TweenService:Create(newModel.Room.Block , info , goal)

The above code will tween the size of the room in 4 seconds with an easing style of quint and an easing direction of in. You can change this in the info variable.

If you want to cancel or pause the tween, you can do tween.Cancel() or tween.Pause() respectively. I do not know all the details of your implementation but the above code would probably go around line 29 where the for loop begins.

Read more about TweenService here: http://wiki.roblox.com/index.php?title=API:Class/TweenService

This discussion is preserved as it was. New answers, comments, and votes are closed.