Randomizing player height, depth and width

so i have this script which randomizes the player height everytime you join, what i want it to do is: when you touch the part your: height, width and depth randomize everytime you touch the brick.

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild('Humanoid')
		for i,Child in pairs(Humanoid:GetChildren()) do
			if Child:IsA('NumberValue')then
				 if Child.Name == 'BodyHeightScale'then
				Child.Value = math.random (1,5)
				
				
				
				end
					if Child.Name == 'BodyWidthScale' then
					Child.Value = math.random(1,2) 
				end
			end
				if Child.Name == 'BodyDepthScale' then
					Child.Value = math.random(2)
				end
					if Child.Name == 'HeadScale' then
					Child.Value = math.random (3)
				end
		end
	end)
end)
1 Like
local debounce = false
part.Touched:Connect(function(hit)
   if not debounce and hit.Parent:FindFirstChildOfClass("Humanoid") and hit.Parent.Humanoid.Health > 0 then
      debounce = true
      --// Code here
      wait(COOLDOWNTIMEHERE)
      debounce = false
   end
end)

do i just add this to the bottom? edit: i just saw the code here place im stupid

part is a part that will be touched. You can define this wherever you would like.

However, if you don’t understand part-touch logic, I can assume you didn’t completely produce the OP code, or you don’t understand why it works.

When it comes to coding, you have to know the “how, what, why, when, and where” of code bits. This means that rather that aimlessly writing code without knowing it’s potential in another project, try to understand bits of it for later usage. This is how many people learn Lua/Roblox and it will make your life much easier.

yea i didnt really make it since i cant script. the site says i cant have people make scripts fully for me so i post here what i am able to find online.

1 Like

Yup, the DevForum is an awesome resource!

If you want more help with code, I can provide some sweet resources here:

well… yeah. but could you still help me with the script though? currently its not working still

1 Like

Are there any errors or warnings in the output?

nope nothing, but the script im using has some extra scripts ill send those: inside of the original script i send there are three more: (the thing wrong with this script is that i dont want it to only change the height but also randomize the depth width and height so you could get some weird creatures from this.

Game.Players.PlayerAdded : then hold true Current "Height" function
	
end
	
	if plr spawn then hold true when ("Reset").save.child.Height
	function
		
	end
		
		
		
		then.child.("BodyWith") if.plr spawn then hold true.that.plr.stays "Height"
			then.child.spawns.then.hold.true.current."Height".then.if.plr.reset.spawn
				same."Height" = "Same Folder,)
			end
		end
			
		end
game.Players.PlayerAdded:Connect then hold true Current "Height" function
	
end
	
	if plr spawn then hold true when ("Reset").save.child.Height
	function
		
	end
		
		
		
		then.child.("HeadScale") if.plr spawn then hold true.that.plr.stays "Height"
			then.child.spawns.then.hold.true.current."Height".then.if.plr.reset.spawn
				same."Height" = "Same Folder,"
			end
		end
			
		end
if Torso.Left Leg.Left Arm.Right Leg.Right Arm = random then if plr spawn in then
	function then save -- This saves Current Height
end end

and inside of the part the original script is in theres another script:

game.workspace.Events.Tilt.OnServerEvent:connect(function(player,pos)
    player.Character.UpperTorso.Waist.C0 = pos
end)

uhhhhhhh…

Those scripts are mumbo-jumbo. They absolutely should be producing errors. There is absolutely ZERO function in these.

You will want to learn the basics of Lua code, as what you have here doesn’t make sense in any coding langauge.

can you atleast for now send a working script

You should only need the information @iGottic has given you to make a working script.

However since you’re still stuck:

local Part = ... --// Part they need to touch

local Debounce = false

local function RandomizeSize(hit) --// Change size of character who touches the block
    if (Debounce == false) then --// Don't let the RandomizeSize function be called too many times in a second.
        Debounce = true

        local Character = hit.Parent --// Get the parent of `hit`
        local Humanoid = Character:FindFirstChild("Humanoid") --// Get a Humanoid from Character if one does exist

        if (Humanoid) then --// Make sure Humanoid exists
            --// Change the size of character
            Humanoid.BodyHeightScale.Value = math.random(1, 5)
            Humanoid.BodyWidthScale.Value = math.random(1, 2)
            Humanoid.BodyDepthScale.Value = math.random(1, 2)
            Humanoid.HeadScale.Value = math.random(1, 3)
        end

        wait(1) --// RandomizeSize can only be "activated" every second
        Debounce = false
    end
end

Part.Touched:Connect(RandomizeSize) --// :Connect the RandomizeSize function to the .Touched signal

Here are some resources if you don’t understand the code:

O_O

2 Likes

i changed the part i need to touch to the partname or does it need to be the path because theres an orange stripe under it, also at the random numbers with the (1, 5) is that that it goes from 1 to 5 and can change in 1 2 3 4 5 and choose random from that?

Test it first. Work out the kinks, and get your pad working :slight_smile:

Please do a google search for something like this. When searching math.random, you get this result: lua-users wiki: Math Library Tutorial

1 Like

To the path of the part.
Ex: workspace.Part

math.random(x, y)```
means generate an integer between or equal to `x` and `y`.

So, `math.random(1, 5)` means 1, 2, 3, 4, and 5.
2 Likes

that worked! also another question regarding this site and not this script, ive posted another thread the same time as this and i wonder what the maximum wait time is normally since ive never been waiting this long for a first response (and that script i didnt get off the internet its made by my scripter of the game but he cant work this weekend so thats why im trying to ask this site to finish it)

when its (1, 1) it doesnt change a bit but when its (0.9, 1) the character becomes super thin, how does 0.1 be such a big difference? edit: currently at (0.99, 1) and it becomes like this image
i basically just want it to become a different shape but not a bigger shape because the game is about growing and otherwise it would defeat the purpose, i only want it to become smaller but not as small as the picture

math.random only accepts integer values.

When you’re randomizing a decimal number and 1, it’s basically the same as randomizing 0 and 1. I don’t know all the specifics but this page may help: math | Documentation - Roblox Creator Hub (Scroll down to random.)

However, if you do this:

local generate = math.random(1, 100)
height = generate / 100

You’ll be able to generate decimal values.

1 Like

so whats the full script? (30 ch)