Making sure value size the same

Hello, so I have this script to check if a boolvalue is true or not and currently it doesn’t check for some reason how would I fix this, here is my code here are the codes used code 1

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if Player.KidValue.Value then
			Player.CurrentTeam.Value = "Loading"
			Player.CurrentTeam.Value = "Kid"
		elseif Player.TeenValue.Value then
			Player.CurrentTeam.Value = "Loading"
			Player.CurrentTeam.Value = "Teen"
		elseif Player.ParentValue.Value then
			Player.CurrentTeam.Value = "Loading"
			Player.CurrentTeam.Value = "Parent"
		end
	end)
end)

code 2

game.Players.PlayerAdded:Connect(function(Player)
	local String = Instance.new("StringValue")
	String.Parent = Player
	String.Name = "CurrentTeam"
	local KidValue = Instance.new("BoolValue")
	KidValue.Parent = Player
	KidValue.Name = "KidValue"
	local TeenValue = Instance.new("BoolValue")
	TeenValue.Parent = Player
	TeenValue.Name = "TeenValue"
	local ParentValue = Instance.new("BoolValue")
	ParentValue.Parent = Player
	ParentValue.Name = "ParentValue"
	Player.PlayerGui:WaitForChild("ChooseTeam").Frame.Kid.MouseButton1Click:Connect(function()
		Player.Character.Humanoid:WaitForChild("BodyWidthScale").Value = 0.6
		Player.character.Humanoid:WaitForChild("BodyDepthScale").Value = 0.6
		Player.character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
		Player.character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
		Player.character.Humanoid:WaitForChild("HeadScale").Value = 0.6
		Player.character.Humanoid:WaitForChild("BodyHeightScale").Value = 0.6
	end)
	Player.PlayerGui:WaitForChild("ChooseTeam").Frame.Teen.MouseButton1Click:Connect(function()
		Player.Character.Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
		Player.character.Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
		Player.character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
		Player.character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
		Player.character.Humanoid:WaitForChild("HeadScale").Value = 0.9
		Player.character.Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
	end)
	Player.PlayerGui:WaitForChild("ChooseTeam").Frame.Parent.MouseButton1Click:Connect(function()
		Player.Character.Humanoid:WaitForChild("BodyWidthScale").Value = 1
		Player.character.Humanoid:WaitForChild("BodyDepthScale").Value = 1
		Player.character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
		Player.character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
		Player.character.Humanoid:WaitForChild("HeadScale").Value = 1
		Player.character.Humanoid:WaitForChild("BodyHeightScale").Value = 1
	end)
end)

code 3

game.Players.PlayerAdded:Connect(function(Player)
	wait(0.1)
	Player.CurrentTeam.Changed:Connect(function(NewValue)
		if NewValue == "Kid" then
			Player.Character.Humanoid:WaitForChild("BodyWidthScale").Value = 0.6
			Player.character.Humanoid:WaitForChild("BodyDepthScale").Value = 0.6
			Player.character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Player.character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Player.character.Humanoid:WaitForChild("HeadScale").Value = 0.6
			Player.character.Humanoid:WaitForChild("BodyHeightScale").Value = 0.6
		elseif NewValue == "Teen" then
			Player.Character.Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
			Player.character.Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
			Player.character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Player.character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Player.character.Humanoid:WaitForChild("HeadScale").Value = 0.9
			Player.character.Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
		elseif NewValue == "Parent" then
			Player.Character.Humanoid:WaitForChild("BodyWidthScale").Value = 1
			Player.character.Humanoid:WaitForChild("BodyDepthScale").Value = 1
			Player.character.Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Player.character.Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Player.character.Humanoid:WaitForChild("HeadScale").Value = 1
			Player.character.Humanoid:WaitForChild("BodyHeightScale").Value = 1
		end
	end)
end)
1 Like

You should just encase all of your scripts into 1 script, that way it’d be less cluttered

game.Players.PlayerAdded:Connect(function(Player)
	local String = Instance.new("StringValue")
	String.Parent = Player
	String.Name = "CurrentTeam"
	local KidValue = Instance.new("BoolValue")
	KidValue.Parent = Player
	KidValue.Name = "KidValue"
	local TeenValue = Instance.new("BoolValue")
	TeenValue.Parent = Player
	TeenValue.Name = "TeenValue"
	local ParentValue = Instance.new("BoolValue")
	ParentValue.Parent = Player
	ParentValue.Name = "ParentValue"

    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

        String.Changed:Connect(function(NewValue)
		    if NewValue == "Kid" then
			    Humanoid:WaitForChild("BodyWidthScale").Value = 0.6
			    Humanoid:WaitForChild("BodyDepthScale").Value = 0.6
			    Humanoid:WaitForChild("BodyProportionScale").Value = 0
			    Humanoid:WaitForChild("BodyTypeScale").Value = 0
			    Humanoid:WaitForChild("HeadScale").Value = 0.6
			    Humanoid:WaitForChild("BodyHeightScale").Value = 0.6
		    elseif NewValue == "Teen" then
			    Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
			    Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
			    Humanoid:WaitForChild("BodyProportionScale").Value = 0
			    Humanoid:WaitForChild("BodyTypeScale").Value = 0
			    Humanoid:WaitForChild("HeadScale").Value = 0.9
			    Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
		    elseif NewValue == "Parent" then
			    Humanoid:WaitForChild("BodyWidthScale").Value = 1
			    Humanoid:WaitForChild("BodyDepthScale").Value = 1
			    Humanoid:WaitForChild("BodyProportionScale").Value = 0
			    Humanoid:WaitForChild("BodyTypeScale").Value = 0
			    Humanoid:WaitForChild("HeadScale").Value = 1
			    Humanoid:WaitForChild("BodyHeightScale").Value = 1
		    end
        end)
    end)
end)

I don’t believe you can detect GuiObjects when they get clicked/activated on the server-side, so you might need to fire a RemoteEvent instead to change the Value that way

But can you show me how I would do this remote event because I tried and kept failing ideas

1 Like

Well, you’d need a RemoteEvent to put inside the ReplicatedStorage Service so that both sides are able to access it whenever they need, and this is what I’d do:

  • Put a couple of LocalScripts inside your GuiObjects that you want to detect
local Player = game.Players.LocalPlayer
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local Button = script.Parent
local TeamType = "Kid"

Button.MouseButton1Down:Connect(function()
    Event:FireServer(TeamType)
end)

And on the server side, you can add another Event which would detect the RemoteEvent being fired onto the server to change the TeamValue:

local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

game.Players.PlayerAdded:Connect(function(Player)
	local String = Instance.new("StringValue")
	String.Parent = Player
	String.Name = "CurrentTeam"
	local KidValue = Instance.new("BoolValue")
	KidValue.Parent = Player
	KidValue.Name = "KidValue"
	local TeenValue = Instance.new("BoolValue")
	TeenValue.Parent = Player
	TeenValue.Name = "TeenValue"
	local ParentValue = Instance.new("BoolValue")
	ParentValue.Parent = Player
	ParentValue.Name = "ParentValue"

    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

        String.Changed:Connect(function(NewValue)
		    if NewValue == "Kid" then
			    Humanoid:WaitForChild("BodyWidthScale").Value = 0.6
			    Humanoid:WaitForChild("BodyDepthScale").Value = 0.6
			    Humanoid:WaitForChild("BodyProportionScale").Value = 0
			    Humanoid:WaitForChild("BodyTypeScale").Value = 0
			    Humanoid:WaitForChild("HeadScale").Value = 0.6
			    Humanoid:WaitForChild("BodyHeightScale").Value = 0.6
		    elseif NewValue == "Teen" then
			    Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
			    Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
			    Humanoid:WaitForChild("BodyProportionScale").Value = 0
			    Humanoid:WaitForChild("BodyTypeScale").Value = 0
			    Humanoid:WaitForChild("HeadScale").Value = 0.9
			    Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
		    elseif NewValue == "Parent" then
			    Humanoid:WaitForChild("BodyWidthScale").Value = 1
			    Humanoid:WaitForChild("BodyDepthScale").Value = 1
			    Humanoid:WaitForChild("BodyProportionScale").Value = 0
			    Humanoid:WaitForChild("BodyTypeScale").Value = 0
			    Humanoid:WaitForChild("HeadScale").Value = 1
			    Humanoid:WaitForChild("BodyHeightScale").Value = 1
		    end
        end)
    end)
end)

Event.OnServerEvent:Connect(function(Player, TeamType)
    Player.CurrentTeam.Value = TeamType
end)

So that way the String.Changed event would detect the new value being changes

1 Like

I tried this script and tried to add this script to it, and it did not work, all I need is it to save the value after they die and keep their size

game.Players.PlayerAdded:Connect(function(LocalPlayer)
	LocalPlayer.CharacterAdded:Connect(function(Character)
		Character:WaitForChild("Humanoid").Died:Connect(function()
			LocalPlayer.CurrentTeam.Value = "Loading.."
			LocalPlayer.CurrentTeam.Value = "Kid"
		end)
	end)
end)
1 Like
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")

game.Players.PlayerAdded:Connect(function(Player)
	local String = Instance.new("StringValue")
	String.Parent = Player
	String.Name = "CurrentTeam"
	local KidValue = Instance.new("BoolValue")
	KidValue.Parent = Player
	KidValue.Name = "KidValue"
	local TeenValue = Instance.new("BoolValue")
	TeenValue.Parent = Player
	TeenValue.Name = "TeenValue"
	local ParentValue = Instance.new("BoolValue")
	ParentValue.Parent = Player
	ParentValue.Name = "ParentValue"

    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")

		if String.Value == "Kid" then
			Humanoid:WaitForChild("BodyWidthScale").Value = 0.6
			Humanoid:WaitForChild("BodyDepthScale").Value = 0.6
			Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Humanoid:WaitForChild("BodyTypeScale").Value = 0
		    Humanoid:WaitForChild("HeadScale").Value = 0.6
			Humanoid:WaitForChild("BodyHeightScale").Value = 0.6
	    elseif NewValue == "Teen" then
			Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
			Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
		    Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Humanoid:WaitForChild("HeadScale").Value = 0.9
			Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
		elseif NewValue == "Parent" then
			Humanoid:WaitForChild("BodyWidthScale").Value = 1
			Humanoid:WaitForChild("BodyDepthScale").Value = 1
			Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Humanoid:WaitForChild("HeadScale").Value = 1
			Humanoid:WaitForChild("BodyHeightScale").Value = 1
		end
    end)
end)

Event.OnServerEvent:Connect(function(Player, TeamType)
    local Character = Player.Character
    Player.CurrentTeam.Value = TeamType

		if TeamType == "Kid" then
			Humanoid:WaitForChild("BodyWidthScale").Value = 0.6
			Humanoid:WaitForChild("BodyDepthScale").Value = 0.6
			Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Humanoid:WaitForChild("BodyTypeScale").Value = 0
		    Humanoid:WaitForChild("HeadScale").Value = 0.6
			Humanoid:WaitForChild("BodyHeightScale").Value = 0.6
	    elseif TeamType == "Teen" then
			Humanoid:WaitForChild("BodyWidthScale").Value = 0.9
			Humanoid:WaitForChild("BodyDepthScale").Value = 0.9
		    Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Humanoid:WaitForChild("HeadScale").Value = 0.9
			Humanoid:WaitForChild("BodyHeightScale").Value = 0.9
		elseif TeamType == "Parent" then
			Humanoid:WaitForChild("BodyWidthScale").Value = 1
			Humanoid:WaitForChild("BodyDepthScale").Value = 1
			Humanoid:WaitForChild("BodyProportionScale").Value = 0
			Humanoid:WaitForChild("BodyTypeScale").Value = 0
			Humanoid:WaitForChild("HeadScale").Value = 1
			Humanoid:WaitForChild("BodyHeightScale").Value = 1
		end
end)

You’d probably need to do something like this then :thinking:

1 Like

With a few edits this seemed to worked perfect, thank you, have a nice day, and your answer was marked as solution!