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)
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
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