local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Pin = game.Workspace.Pin
Mouse.Move:Connect(function()
local Target = Mouse.Target
if Target then
if Target.Name == "Pin" then
for i = 0, 1, 0.001 do
Pin.Size = Pin.Size:Lerp(Vector3.new(1.292, 1.82, 1.238), i)
end
end
end
end)
The goal of the script above is to gradually increase the size of a part when the player’s mouse is hovering over it. It works all well and good except for two factors. The part does not gradually increase in size, it is an abrupt increase. The part also does not return to it’s normal size after the player’s mouse has left it. Does anybody know how to fix the gradual increase and make the part return to it’s normal size after the player’s mouse has left it?
Got the size to increase gradually by adding a wait()
https://gyazo.com/f15f614f6fb5b1cd1235e892be2c63c9
Now there’s just the issue of making it return to it’s original size.
1 Like
Just set the size to it’s original size as soon as Mouse.Target isn’t your pin anymore.
local Pin = game.Workspace.Pin
local OriginalSize = Pin.Size
if Target.Name == "Pin" then
for i = 0, 1, 0.001 do
Pin.Size = Pin.Size:Lerp(Vector3.new(1.292, 1.82, 1.238), i)
end
else -- Mouse isn't on Pin anymore
Pin.Size = OriginalSize
end
1 Like
But I need it to gradually decrease from the larger size to the smaller size once the mouse has left it, that’s an abrupt decrease
1 Like
Actually tried this just a second ago, it only works the first time, then it starts to freak out.
https://gyazo.com/d598242cf9d4486cffaa988fcbad9db0
1 Like
Use the TweenService:
local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Info = TweenInfo.new(5)
local YourPart = workspace.Pin
local OriginalSize = YourPart.Size
local YourEndSize = OriginalSize + Vector3.new(5,5,5)
local YourPartCFrame = YourPart.CFrame
local GrowTable = {}
GrowTable.Size = YourEndSize
GrowTable.CFrame = YourPartCFrame
local ShrinkTable = {}
ShrinkTable.Size = OriginalSize
ShrinkTable.CFrame = YourPartCFrame
local GrowTween = TweenService:Create(YourPart, Info, GrowTable)
local ShrinkTween = TweenService:Create(YourPart, Info, ShrinkTable)
Mouse.Move:Connect(function()
local Target = Mouse.Target
if Target then
if Target.Name == "Pin" then
GrowTween:Play()
end
else
ShrinkTween:Play()
end
end)
Hope this help you @BIueMalibu
P.S.: Sorry, i have forgot to write create with a capital „C“. You can add many EasingStyles and EasingDirection, Callbackfunctions and more.
1 Like