In one of my games, you grow when touching a part, similar to growing in Agar.io, but for some reason, it acts stangely. I’ll leave code samples at the bottom.
When you die, a value is saved in your player that is your size, so lets say your size was 5, 5, 5, the value in your player would be 5, 5, 5, then when you respawn, it sets you back to that size so you don’t lose your progress. However, when your size increases again from one of the intractable items, your size goes back down to what it was before being set to 5, 5, 5.
I would say that I’ve tried some stuff, but I really haven’t. I have no idea what to do.
Resize after spawn (LocalScript):
function onDeath()
game.Players.LocalPlayer.Size.Value = game.Players.LocalPlayer.Character.HumanoidRootPart.Size
wait(0.31)
for i, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:IsA("Accessory") then
local part = v:FindFirstChild("Handle")
part.Size = Vector3.new(game.Players.LocalPlayer.Size.Value.X, game.Players.LocalPlayer.Size.Value.Y, game.Players.LocalPlayer.Size.Value.Z)
end
end
game.Players.LocalPlayer.Character.Head.Size = Vector3.new(game.Players.LocalPlayer.Size.Value.X, game.Players.LocalPlayer.Size.Value.Y, game.Players.LocalPlayer.Size.Value.Z)
game.Players.LocalPlayer.Character.HumanoidRootPart.Size = Vector3.new(game.Players.LocalPlayer.Size.Value.X, game.Players.LocalPlayer.Size.Value.Y, game.Players.LocalPlayer.Size.Value.Z)
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(onDeath)
end
repeat
wait()
until game.Players.LocalPlayer.Character
game.Players.PlayerAdded:Connect(function(player)
local size = Instance.new("Vector3Value")
size.Name = "Size"
size.Value = player
end)
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(onDeath)
Grow script (Inside touchable part, normal script):
local Players = game:GetService("Players")
debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
debounce = true
for i, v in pairs(hit.Parent:GetChildren()) do
if v:IsA("Accessory") then
local part = v:FindFirstChild("Handle")
part.Size = Vector3.new(part.Size.X + 0.1, part.Size.Y + 0.1, part.Size.Z + 0.1)
end
end
hit.Parent.Head.Size = Vector3.new(hit.Parent.Head.Size.X + 0.1, hit.Parent.Head.Size.Y + 0.1, hit.Parent.Head.Size.Z + 0.1)
hit.Parent.HumanoidRootPart.Size = Vector3.new(hit.Parent.HumanoidRootPart.Size.X + 0.1, hit.Parent.HumanoidRootPart.Size.Y + 0.1, hit.Parent.HumanoidRootPart.Size.Z + 0.1)
local player = Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
script.Parent:Destroy()
end
end)