Hello, I am doing a script where you will grow when clicking with a tool, but I need a limit for the size.
I tried doing a script and I searched but I didn’t get a good answer.
This is my script:
player.CharacterAppearanceLoaded:Connect(function(character)
local humanoid = character.Humanoid
if humanoid:WaitForChild("BodyDepthScale").Value >= 15000 then
return 15000 end
if humanoid:WaitForChild("BodyHeightScale").Value >= 15000 then
return 15000 end
if humanoid:WaitForChild("BodyWidthScale").Value >= 15000 then
return 15000 end
if humanoid:WaitForChild("HeadScale").Value >= 15000 then
return 15000 end
humanoid:WaitForChild("BodyDepthScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("BodyHeightScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("BodyWidthScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("HeadScale").Value = 1 + (strength.Value / 1500)
humanoid.WalkSpeed = 16 + (strength.Value / 100)
strength:GetPropertyChangedSignal("Value"):Connect(function()
humanoid = character.Humanoid
humanoid:WaitForChild("BodyDepthScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("BodyHeightScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("BodyWidthScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("HeadScale").Value = 1 + (strength.Value / 1500)
humanoid.WalkSpeed = 16 + (strength.Value / 100)
end)
end)
How can I fix this?
1 Like
What specifically won’t work? the whole script or just the player’s size isn’t changing? Are there any errors in the output?
No errors, the player size has to change to 15000 after going above.
If I don’t explain myself, what I am trying to do is that this script will detect for the player’s size to be above 15000 and if it is above 15000, then change the size to 15000 and like that.
if humanoid:WaitForChild("BodyDepthScale").Value >= 15000 then
return 15000 end
if humanoid:WaitForChild("BodyHeightScale").Value >= 15000 then
return 15000 end
if humanoid:WaitForChild("BodyWidthScale").Value >= 15000 then
return 15000 end
if humanoid:WaitForChild("HeadScale").Value >= 15000 then
return 15000 end
I’m pretty sure it doesn’t work this way. You’re suppose to set the values like below.
if humanoid:WaitForChild("HeadScale").Value >= 15000 then
humanoid.HeadScale.Value = 15000
end
--- Do the same thing for the other ones
That’s a little vague. Which line in your script is “line 68”? Doesn’t seem like it’s part of our original problem anymore.
player.CharacterAppearanceLoaded:Connect(function(character)
local humanoid = character.Humanoid
if humanoid:WaitForChild("BodyDepthScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
if humanoid:WaitForChild("BodyHeightScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
if humanoid:WaitForChild("BodyWidthScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
if humanoid:WaitForChild("HeadScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
end
humanoid:WaitForChild("BodyDepthScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("BodyHeightScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("BodyWidthScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("HeadScale").Value = 1 + (strength.Value / 1500)
humanoid.WalkSpeed = 16 + (strength.Value / 100)
strength:GetPropertyChangedSignal("Value"):Connect(function()
humanoid = character.Humanoid
humanoid:WaitForChild("BodyDepthScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("BodyHeightScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("BodyWidthScale").Value = 1 + (strength.Value / 1500)
humanoid:WaitForChild("HeadScale").Value = 1 + (strength.Value / 1500)
humanoid.WalkSpeed = 16 + (strength.Value / 100)
end)
end) -- this
The rest behind is the leaderstats values, and also the leaderboard won’t show when playing.
if humanoid:WaitForChild("BodyDepthScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
if humanoid:WaitForChild("BodyHeightScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
if humanoid:WaitForChild("BodyWidthScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
if humanoid:WaitForChild("HeadScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
end
Each if block must end with an ‘end’.
if humanoid:WaitForChild("BodyDepthScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
end
if humanoid:WaitForChild("BodyHeightScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
end
if humanoid:WaitForChild("BodyWidthScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
end
if humanoid:WaitForChild("HeadScale").Value > 15000 then
humanoid.HeadScale.Value = 15000
end
Also change the ‘.HeadScale.Value’ to the right limbs. You don’t want all of them to change the headscale.
2 Likes
i’m guessing that your’re saying that your script does “work” it just doesn’t do what you want it to. Also i’m guessing you have more to your script right?, because you are using a player
variable up there. it’s likely not working how you want it to because you aren’t limiting the size in your strength event and when you do return 15000
you are stopping the rest from running and this isn’t really “returning” to anything (like swordphin mentioned) . What i would do is use math.clamp
instead and do something like this:
local MinSize = 1 --- you can change these
local MaxSize = 15000
local function SetSize(humanoid, size)
humanoid:WaitForChild("BodyDepthScale").Value = size
humanoid:WaitForChild("BodyHeightScale").Value = size
humanoid:WaitForChild("BodyWidthScale").Value = size
humanoid:WaitForChild("HeadScale").Value = size
end
player.CharacterAppearanceLoaded:Connect(function(character)
local humanoid = character.Humanoid
local Size = math.clamp( 1 + (strength.Value / 1500), MinSize, MaxSize)
SetSize(humanoid, Size)
humanoid.WalkSpeed = 16 + (strength.Value / 100)
strength:GetPropertyChangedSignal("Value"):Connect(function()
local humanoid = character.Humanoid
local Size = math.clamp( 1 + (strength.Value / 1500), MinSize, MaxSize)
SetSize(humanoid, Size)
humanoid.WalkSpeed = 16 + (strength.Value / 100)
end)
end)
Also you have strength
defined somewhere right?
1 Like
Yeah, it’s on the first lines of the script.
1 Like
Changed it, but the error will still display saying that it expected end to close a function but if I add end then it will show that global player or global character is unknown.
1 Like
I tried your script and it worked, it won’t grow after reaching the value!
2 Likes