I made a script that works in a weird way

I am currently making a script where when someone touches a part they get fatter, but for some reason when they touch that part it makes them taller.
Here is the script:

local part = script.Parent

-- Function that increases player's size
local function increaseSize(player)
	local humanoidRootPart = player.Character.HumanoidRootPart
	humanoidRootPart.Size = humanoidRootPart.Size * 1.5 -- Increase size by 50%
end

-- When a player touches the part, increase their size, destroy the part, and print a message
part.Touched:Connect(function(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player then
		increaseSize(player)
		part:Destroy() -- Destroy the part
		print(player.Name .. " touched the part and got bigger!") -- Print a message
	end
end)

Use R6, then resize BaseParts to get the desired effect. HumanoidRootPart doesn’t make the player larger.

Change up this script I found:

local Percentage = 0.3 -- 1 = normal, 0.5 = half your normal size, 2 = double your normal size
local LastGrowth = 0

script.Parent.Touched:Connect(function(Hit)
	if time() - LastGrowth > 1 then
		LastGrowth = time()
	
		local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		
		if Player and Player.Character:FindFirstChild("AppliedGrowth") == nil then
			local Motors = {}
			local NewMotors = {}
			local NewVal = Instance.new("BoolValue")
			NewVal.Name = "AppliedGrowth"
			NewVal.Parent = Player.Character
			
			
			for i,v in pairs(Player.Character.Torso:GetChildren()) do
				if v:IsA("Motor6D") then
					table.insert(Motors, v)
				end
			end
			table.insert(Motors, Player.Character.HumanoidRootPart.RootJoint)
			
			for i,v in pairs(Motors) do

				local X, Y, Z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = v.C0:components()
				X = X * Percentage
				Y = Y * Percentage
				Z = Z * Percentage
				R00 = R00 * Percentage
				R01 = R01 * Percentage
				R02 = R02 * Percentage
				R10 = R10 * Percentage
				R11 = R11 * Percentage
				R12 = R12 * Percentage
				R20 = R20 * Percentage
				R21 = R21 * Percentage
				R22 = R22 * Percentage
				v.C0 = CFrame.new(X, Y, Z, R00, R01, R02, R10, R11, R12, R20, R21, R22)
				
				local X, Y, Z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = v.C1:components()
				X = X * Percentage
				Y = Y * Percentage
				Z = Z * Percentage
				R00 = R00 * Percentage
				R01 = R01 * Percentage
				R02 = R02 * Percentage
				R10 = R10 * Percentage
				R11 = R11 * Percentage
				R12 = R12 * Percentage
				R20 = R20 * Percentage
				R21 = R21 * Percentage
				R22 = R22 * Percentage
				v.C1 = CFrame.new(X, Y, Z, R00, R01, R02, R10, R11, R12, R20, R21, R22)
				
				table.insert(NewMotors, {v:Clone(), v.Parent})
				v:Destroy()
			end
			
			for i,v in pairs(Player.Character:GetChildren()) do
				if v:IsA("BasePart") then
					v.Size = v.Size * Percentage
				end
			end
			
			for i,v in pairs(NewMotors) do
				v[1].Parent = v[2]
			end
			
			
		end
	end
end)

Thing is, in my custom model I am using I have humanoid, HumanoidRootPart and Torso. I tried this script and made it r6 but didnt work

Why, did you get any errors?

Yes, 14:47:36.746 RootJoint is not a valid member of Part “Workspace.kingofdome21.HumanoidRootPart” - Server - Script:23

this would be perfect for obbys

Try now sizing the root joint?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.