Hello, so recently I implemented a script into my game which when you join the game a gui appears, and you have the option of a kid, teen, or parent, and on parent when you pick it everything is fine, but when you respawn with your current screen being parent this happens:
I have no idea what can cause this, I have tried moving spawn locations up, but it still seems to happen, so I am guessing this is the script. Thought I don’t know how to fix it.
Script:
print("hi")
local teamSizeIndex = {
--your teams don’t have to be named the same way, this is just an example
Parents = 1,
Teens = 0.9,
Kids = 0.85
}
local function updateSize(player)
print("HIIIIIIIIIIIIIIIIIII 2")
wait(0.5)
-- give a little bit of time for things to load
if player.Team then -- make sure the player has a team, or else the function will error
local char = player.Character
local size = teamSizeIndex[player.Team.Name]
char.Humanoid.BodyHeightScale.Value *= size-- compound operators are Awesome
char.Humanoid.BodyWidthScale.Value *= size
char.Humanoid.BodyDepthScale.Value *= size
char.Humanoid.HeadScale.Value *= size
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
updateSize(player)
end)
player:GetPropertyChangedSignal("Team"):Connect(function()
print(player.Team)
updateSize(player)
end)
end)
print("hi")
local teamSizeIndex = {
--your teams don’t have to be named the same way, this is just an example
Parents = 1,
Teens = 0.9,
Kids = 0.85
}
local function updateSize(player)
print("HIIIIIIIIIIIIIIIIIII 2")
wait(0.5)
-- give a little bit of time for things to load
if player.Team then -- make sure the player has a team, or else the function will error
local char = player.Character
local size = teamSizeIndex[player.Team.Name]
char.Humanoid.BodyHeightScale.Value *= size-- compound operators are Awesome
char.Humanoid.BodyWidthScale.Value *= size
char.Humanoid.BodyDepthScale.Value *= size
char.Humanoid.HeadScale.Value *= size
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
updateSize(player)
end)
player:GetPropertyChangedSignal("Team"):Connect(function()
print(player.Team)
updateSize(player)
end)
end)
Not sure exactly what the problem is, but I did notce this. You’ll want to not call that variable char as I believe that’s a data type in lua, representing characters (indicated by char being blue). So perhaps try changing that to character instead.
Also, Is the player’s body size changing correctly, or is that part not working?
if player.Team then -- make sure the player has a team, or else the function will error
local char = player.Character
local size = teamSizeIndex[player.Team.Name]
char:MoveTo(char.HumanoidRootPart.Position + Vector3.new(0,3,0)) -- or whatever height u want to move it to
char.Humanoid.BodyHeightScale.Value *= size-- compound operators are Awesome
char.Humanoid.BodyWidthScale.Value *= size
char.Humanoid.BodyDepthScale.Value *= size
char.Humanoid.HeadScale.Value *= size
end
end
print("hi")
local teamSizeIndex = {
--your teams don’t have to be named the same way, this is just an example
Parents = 1,
Teens = 0.9,
Kids = 0.85
}
local function updateSize(player)
print("HIIIIIIIIIIIIIIIIIII 2")
wait(0.5)
-- give a little bit of time for things to load
if player.Team then -- make sure the player has a team, or else the function will error
local character = player.Character
local size = teamSizeIndex[player.Team.Name]
character:MoveTo(character.HumanoidRootPart.Position + Vector3.new(0,3,0))
character.Humanoid.BodyHeightScale.Value *= size-- compound operators are Awesome
character.Humanoid.BodyWidthScale.Value *= size
character.Humanoid.BodyDepthScale.Value *= size
character.Humanoid.HeadScale.Value *= size
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
updateSize(player)
end)
player:GetPropertyChangedSignal("Team"):Connect(function()
print(player.Team)
updateSize(player)
end)
end)
EDIT: If the above works, please give the solution to @udi_g because it was his original idea.