hello, I’m making a script that able to make player grow neck (controllable)
This is my current script: its working but not what I expected, is there a better solution?
local character = player.Character or player.CharacterAdded:Wait()
local neck = character:FindFirstChild("Neck")
local head = character:FindFirstChild("Head")
if not neck or not head then
warn("Neck or Head not found in the giraffe model.")
return
end
local growthDirection = Vector3.new(0, 1, 0)
local growthRate = 0.5
local maxGrowth = 5
function growNeck()
local currentNeckCount = 0
for _, part in pairs(character:GetChildren()) do
if part.Name == "Neck" then
currentNeckCount = currentNeckCount + 1
end
end
if currentNeckCount < maxGrowth then
local newNeck = neck:Clone()
newNeck.Parent = character
newNeck.Position = neck.Position + growthDirection * (neck.Size.Y * currentNeckCount)
head.Position = newNeck.Position + Vector3.new(0, newNeck.Size.Y / 2 + 1, 0)
else
print("Maximum neck growth reached.")
end
end
function growHorizon()
local currentNeckCount = 0
for _, part in pairs(character:GetChildren()) do
if part.Name == "Neck" then
currentNeckCount = currentNeckCount + 1
end
end
if currentNeckCount < maxGrowth then
local newNeck = neck:Clone()
newNeck.Parent = character
newNeck.Position = neck.Position + Vector3.new(1, 0, 0) * (neck.Size.X * currentNeckCount)
head.Position = newNeck.Position + Vector3.new( newNeck.Size.X / 2+1, 0, 0)
else
print("Maximum neck growth reached.")
end
end
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.F then
growNeck()
end
if input.KeyCode == Enum.KeyCode.R then
growHorizon()
end
end
end)```