Character sizer not working

Im trying to make something that resizes the player with the click of a button

At first it said in the output: Attempt to index nil with “Humanoid”
but after a couple more tests (Without editing anything)
The error stopped appearing.

Here is my code

game.ReplicatedStorage.becomegiant.OnServerEvent:Connect(function(name)
	print(name)
	local Character = game.Workspace:WaitForChild(name)
local setup = game.Players:FindFirstChild(name)
	Character.Humanoid.Health = Character.Humanoid.Health - 100
	wait(3.5)
	
	setup.PlayerScripts.isGiant = true
	
	Character.Humanoid.WalkSpeed = 50
	Character.Humanoid.JumpPower = 150
	Character.Humanoid.MaxHealth = 1000
	Character.Humanoid.Health = 1000
    Character.Humanoid.BodyDepthScale.Value = 10
    Character.Humanoid.BodyHeightScale.Value = 9
	Character.Humanoid.BodyWidthScale.Value = 10
	
	end)

any idea whats happening?

Ok, a few things.

This is not the player name, this is already the player.
So remove:

(Also change where it says setup to player and where it says name to player)

And change:

To:
local Character = player.Character or player.CharacterAdded:Wait()

Do I need to create a variable for the players service in order for this line to work?

No, its already inside the player, you don’t need any service

it still doesnt work the output says: attempt to index nil with Character
note: (This script is activated by a remote event which is activated by a textbutton)

That means you don’t have a player. Change the first line to this

game.ReplicatedStorage.becomegiant.OnServerEvent:Connect(function(player)
1 Like

it works! Thanks a lot. I spent an hour trying to wrap my head around this.

Please mark @domboss37 's answer as the solution if it worked

Im currently in the process of doing that.


game.ReplicatedStorage.becomegiant.OnServerEvent:Connect(function(player)
	local Character = player.Character
	Character.Humanoid.Health = Character.Humanoid.Health - 100
	wait(3.5)
	
	player.PlayerScripts.isGiant = true

Character.Humanoid.WalkSpeed = 50
	Character.Humanoid.JumpPower = 150
	Character.Humanoid.MaxHealth = 1000
    Character.Humanoid.Health = 1000
    Character.Humanoid.BodyDepthScale.Value = 10
    Character.Humanoid.BodyHeightScale.Value = 9
	Character.Humanoid.BodyWidthScale.Value = 10
	
end)

Hopefully this works

Edit: I didn’t realize that a solution was found already

Thats ok, but thanks for helping anyways.

1 Like