Hi, whenever a player touches a block, they shrink. How do I dlowly shrink the player instead of an instant one? Here is my working code:
local Touch
local RoundModule = require(script.RoundModule)
Touch = script.Parent.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if (Player) then
local NPS = Player:FindFirstChild("NormalPlayerSize")
local P = Player:FindFirstChild("Piggy")
if (NPS) and (not P) then
local Humanoid = Player.Character:FindFirstChild("Humanoid")
if Humanoid then
local HD = Humanoid:GetAppliedDescription()
HD.HeadScale = HD.HeadScale * .4
HD.DepthScale = HD.DepthScale * .4
HD.WidthScale = HD.WidthScale * .4
HD.HeightScale = HD.HeightScale * .4
Humanoid:ApplyDescription(HD)
end
NPS:Destroy()
RoundModule.InsertTag(Player, "SmallPlayer")
end
end
end)
You should use a for i = loop. Seeing as how the player’s size is reduced by .4, you should use for i = 1,4 and HD.HeadScale = HD.HeadScale * i/10. Put all 4 scale lines of code into a for loop all using the same formula. If you multiply the second number of the for i = loop (e.x. i = 1,8/1,16), and you multiply the 10 by the same multiple (e.x. i/20 or i/40), it would give a smoother effect. Remember to use a wait()
Alright, I whipped one up but the .4 at the beginning is underlined, how would i fix this?
for i, .4, .1 do
local HD = Humanoid:GetAppliedDescription()
HD.HeadScale = HD.HeadScale * i
HD.DepthScale = HD.DepthScale * i
HD.WidthScale = HD.WidthScale * i
HD.HeightScale = HD.HeightScale * i
Humanoid:ApplyDescription(HD)
end
Here’s the current script, the player shrunk too small. Would you know how to fix this?
local Touch
local RoundModule = require(script.RoundModule)
Touch = script.Parent.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if (Player) then
local NPS = Player:FindFirstChild("NormalPlayerSize")
local P = Player:FindFirstChild("Piggy")
if (NPS) and (not P) then
local Humanoid = Player.Character:FindFirstChild("Humanoid")
if Humanoid then
for i = 1, 4, 1 do
local HD = Humanoid:GetAppliedDescription()
HD.HeadScale = HD.HeadScale * i/10
HD.DepthScale = HD.DepthScale * i/10
HD.WidthScale = HD.WidthScale * i/10
HD.HeightScale = HD.HeightScale * i/10
Humanoid:ApplyDescription(HD)
wait(.2)
end
end
NPS:Destroy()
RoundModule.InsertTag(Player, "SmallPlayer")
end
end
end)
It’s because you’re using the current Scales when you multiply.
Save a variable referencing the old values.
local HeadScale = HD.HeadScale
local DepthScale = HD.DepthScale
local WidthScale = HD.WidthScale
local HeightScale = HD.HeightScale
for i = 1, 4 do
local HD = Humanoid:GetAppliedDescription()
HD.HeadScale = HeadScale * i / 10
HD.DepthScale = DepthScale * i / 10
HD.WidthScale = WidthScale * i / 10
HD.HeightScale = HeightScale * i / 10
Humanoid:ApplyDescription(HD)
wait(.2)
end
I haven’t looked at your script much but there are some values inside the humanoid (i think) where you can change the height, width, etc. scale. You can use TweenService to shrink them smoothly
local Touch
local RoundModule = require(script.RoundModule)
Touch = script.Parent.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if (Player) then
local NPS = Player:FindFirstChild("NormalPlayerSize")
local P = Player:FindFirstChild("Piggy")
if (NPS) and (not P) then
local Humanoid = Player.Character:FindFirstChild("Humanoid")
if Humanoid then
local HD = Humanoid:GetAppliedDescription()
for i = 1, 4 do
HD.HeadScale = HD.HeadScale * i/10
HD.DepthScale = HD.DepthScale * i/10
HD.WidthScale = HD.WidthScale * i/10
HD.HeightScale = HD.HeightScale * i/10
end
Humanoid:ApplyDescription(HD)
end
NPS:Destroy()
RoundModule.InsertTag(Player, "SmallPlayer")
end
end
end)