So i made this Race system, I was wondering if exploiters will be able to change their race from the client like changing the stringvalue value. If so can you explain me how to prevent that?
local totalRarity = 0
for _, race in ipairs(races) do
totalRarity = totalRarity + race.rarity
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local RaceValue = Instance.new("StringValue", character)
local randomRarity = math.random(1, totalRarity)
local selectedRace
local cumulativeRarity = 0
for _, race in ipairs(races) do
cumulativeRarity = cumulativeRarity + race.rarity
if randomRarity <= cumulativeRarity then
selectedRace = race
break
end
end
RaceValue.Name = "Race"
RaceValue.Value = selectedRace.name
character["Body Colors"].HeadColor = selectedRace.skincolor
character["Body Colors"].LeftArmColor = selectedRace.skincolor
character["Body Colors"].RightArmColor = selectedRace.skincolor
character["Body Colors"].LeftLegColor = selectedRace.skincolor
character["Body Colors"].RightLegColor = selectedRace.skincolor
character["Body Colors"].TorsoColor = selectedRace.skincolor
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.MaxHealth = selectedRace.health
humanoid.Health = selectedRace.health
end
end)
end)