#Shrinking system only works once
1 messages · Page 1 of 1 (latest)
-- server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local remote = ReplicatedStorage:WaitForChild("Remotes").Commands.Panel.Shrink
local stopRemote = ReplicatedStorage:WaitForChild("Remotes").Commands.Panel.StopShrink
local continueRemote = ReplicatedStorage:WaitForChild("Remotes").Commands.Panel.ContinueShrink
local part = script.Parent
local currentTween = nil
local isTweening = false
remote.OnServerEvent:Connect(function(player, amount, speed)
local currentSize = part.Size
local newY = math.clamp(currentSize.Y + amount, 0.1, 100)
local newZ = math.clamp(currentSize.Z + amount, 0.1, 100)
local targetSize = Vector3.new(currentSize.X, newY, newZ)
if currentTween then
currentTween:Cancel()
isTweening = false
end
local tweenInfo = TweenInfo.new(speed, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
currentTween = TweenService:Create(part, tweenInfo, {Size = targetSize})
currentTween:Play()
isTweening = true
end)
stopRemote.OnServerEvent:Connect(function()
if currentTween and isTweening then
currentTween:Pause()
isTweening = false
end
end)
continueRemote.OnServerEvent:Connect(function()
if currentTween and not isTweening then
currentTween:Play()
isTweening = true
end
end)
--local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remote = ReplicatedStorage:WaitForChild("Remotes").Commands.Panel.Shrink
local stopRemote = ReplicatedStorage:WaitForChild("Remotes").Commands.Panel.StopShrink
local continueRemote = ReplicatedStorage:WaitForChild("Remotes").Commands.Panel.ContinueShrink
local frame = script.Parent.Frame
local sizeBox = frame.size
local speedBox = frame.Speed
local stopButton = frame.Stop
local continueButton = frame.Continue
local function sendValues()
local sizeInput = tonumber(sizeBox.Text)
local speedInput = tonumber(speedBox.Text)
if sizeInput and sizeInput >= 0 and sizeInput <= 1 and speedInput and speedInput > 0 then
remote:FireServer(sizeInput, speedInput)
end
end
sizeBox.FocusLost:Connect(function(enterPressed)
if enterPressed then
sendValues()
end
end)
speedBox.FocusLost:Connect(function(enterPressed)
if enterPressed then
sendValues()
end
end)
stopButton.MouseButton1Click:Connect(function()
stopRemote:FireServer()
end)
continueButton.MouseButton1Click:Connect(function()
continueRemote:FireServer()
end)```