ChangeSizeScript Not working

Hello, I have this script to make sure the player stays the same size when they die, but it doesn’t work, I really need some help on this, heres the code

game.Players.PlayerAdded:Connect(function(LocalPlayer)
	LocalPlayer.CharacterAdded:Connect(function(Character)
		local char = LocalPlayer.Character or LocalPlayer.Character:Wait()
		if LocalPlayer.CurrentTeam.Value == "Kid" then
			LocalPlayer.char:WaitForChild("Humanoid"):WaitForChild("BodyWidthScale").Value = 0.6
			LocalPlayer.char:WaitForChild("Humanoid"):WaitForChild("BodyDepthScale").Value = 0.6
			LocalPlayer.char:WaitForChild("Humanoid"):WaitForChild("BodyProportionScale").Value = 0
			LocalPlayer.char:WaitForChild("Humanoid"):WaitForChild("BodyTypeScale").Value = 0
			LocalPlayer.char:WaitForChild("Humanoid"):WaitForChild("HeadScale").Value = 0.6
			LocalPlayer.char:WaitForChild("Humanoid"):WaitForChild("BodyHeightScale").Value = 0.6
		end
		if LocalPlayer.CurrentTeam.Value == "Teen" then
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyProportionScale").Value = 0
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyTypeScale").Value = 0
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("HeadScale").Value = 0.9
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
		end

		if LocalPlayer.CurrentTeam.Value == "Parent" then
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyWidthScale").Value = 1
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyDepthScale").Value = 1
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyProportionScale").Value = 0
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyTypeScale").Value = 0
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("HeadScale").Value = 1
			LocalPlayer:WaitForChild("Character").Humanoid:WaitForChild("BodyHeightScale").Value = 1
		end
	end)
end)

Do you have CurrentTeam defined somewhere else? because it isn’t a default property.

image

what does your output look like?

Nothing in output, ignore the error its for a plugin

have it print something after it changes somethings size and see if that goes through

Nothing printed with this

game.Players.PlayerAdded:Connect(function(LocalPlayer)
	LocalPlayer.CharacterAdded:Connect(function(Character)
		if LocalPlayer.CurrentTeam.Value == "Kid" then
			print("hi")
			Character.Humanoid:WaitForChild("BodyWidthScale").Value = 0.6
			Character.Humanoid:WaitForChild("BodyDepthScale").Value = 0.6
			Character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Character.Humanoid:WaitForChild("HeadScale").Value = 0.6
			Character.Humanoid:WaitForChild("BodyHeightScale").Value = 0.6
			print("hi2")
		elseif LocalPlayer.CurrentTeam.Value == "Teen" then
			Character.Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
			Character.Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
			Character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Character.Humanoid:WaitForChild("HeadScale").Value = 0.9
			Character.Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
		elseif LocalPlayer.CurrentTeam.Value == "Parent" then
			Character.Humanoid:WaitForChild("BodyWidthScale").Value = 1
			Character.Humanoid:WaitForChild("BodyDepthScale").Value = 1
			Character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Character.Humanoid:WaitForChild("HeadScale").Value = 1
			Character.Humanoid:WaitForChild("BodyHeightScale").Value = 1
		end
	end)
end)

And you had your value set to Kid? make sure it’s grammatically correct and is a string aswell.

image

  1. PlayerAdded will not work on a LocalScript tied to the player since the event fires before the PlayerScripts have loaded. Just remove that part and just define LocalPlayer (local LocalPlayer = game.Players.LocalPlayer)
  1. Why are you defining the character completely different in the Kid code compared to all the others.
    Kid Code:

Other code:

game.Players.PlayerAdded:Connect(function(LocalPlayer) its just the parameter name and 2nd it was for testing to see if waiting for it would work, but it never did, if you have any solution to this please say it

what he is saying is that it cannot detect the player being added because you are the player and you arrive alongside the function that would be fired.

Well I have no idea how to fix it, some example code would be helpful

try just at the top saying something like
local player = game.Players.LocalPlayer
instead of the PlayerAdded

and you should probably change LocalPlayer defined at the top for just player

Game.Players.Localplayers only works in localscripts, this is a serverscript.

Try this. (Strictly an example)

function ChangeCharacter(LocalPlayer,Character)
    if LocalPlayer.CurrentTeam.Value == "Kid" then
			print("hi")
			Character.Humanoid:WaitForChild("BodyWidthScale").Value = 0.6
			Character.Humanoid:WaitForChild("BodyDepthScale").Value = 0.6
			Character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Character.Humanoid:WaitForChild("HeadScale").Value = 0.6
			Character.Humanoid:WaitForChild("BodyHeightScale").Value = 0.6
			print("hi2")
		elseif LocalPlayer.CurrentTeam.Value == "Teen" then
			Character.Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
			Character.Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
			Character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Character.Humanoid:WaitForChild("HeadScale").Value = 0.9
			Character.Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
		elseif LocalPlayer.CurrentTeam.Value == "Parent" then
			Character.Humanoid:WaitForChild("BodyWidthScale").Value = 1
			Character.Humanoid:WaitForChild("BodyDepthScale").Value = 1
			Character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Character.Humanoid:WaitForChild("HeadScale").Value = 1
			Character.Humanoid:WaitForChild("BodyHeightScale").Value = 1
		end
end

local LocalPlayer = game.Players.LocalPlayer

LocalPlayer.CharacterAdded:Connect(function(Character)
		ChangeCharacter(LocalPlayer,Character) -- Runs when the player dies/respawns
end)

repeat wait() until LocalPlayer.Character
ChangeCharacter(LocalPlayer,LocalPlayer.Character) --Runs when the Script Loads

Didn’t seem to work, want a copy of the place?

Any errors? Also where are you putting the LocalScript?

This isn’t a localscript haha, its a serverscript and this error ServerScriptService.TeamScripts.ResetTeamSize:31: attempt to index nil with ‘CharacterAdded’