I wrote this peice of code that changed the players bodycolor when they press a button.
When you press it. everyone changes there bodycolor to the color the player pressed.
I dont know how to make it so only 1 player changes color and the others dont.
local BodyColor = game.ReplicatedStorage.CharacterColors.Red["Body Colors"].HeadColor3 --Depending on the button i will change this.
local Plr = game.Players.LocalPlayer
local PlrID = game.Players.LocalPlayer.UserId
local NewBodyColor = {BodyColor.R,BodyColor.B,BodyColor.G}
local ColorSaver = game.ReplicatedStorage.SaveColors
local ColorLoader = game.ReplicatedStorage.LoadColors
script.Parent.MouseButton1Click:Connect(function()
ColorSaver:FireServer(Plr,PlrID, BodyColor.R, BodyColor.G, BodyColor.B)
wait(0.1)
ColorLoader:FireServer(Plr,PlrID, BodyColor.R, BodyColor.G, BodyColor.B)
end)
local LoadEvent = game.ReplicatedStorage.LoadColors
local Char = script.Parent
wait(0.01)
local HRP = Char:FindFirstChildWhichIsA(“Humanoid”)
local PlrColors = Char:FindFirstChildWhichIsA(“BodyColors”)
local Data = game:GetService(“DataStoreService”):GetDataStore(“PlayerColor”)
local PlayerIdFetcher = game.ReplicatedStorage.PlayerID
local PlrID = game.Players:GetPlayerFromCharacter(Char)
– This code is inside StarterCharacterScripts
If you’re changing the bodycolors of the starter character in starterplayer then everytime a player’s character spawns they will have the bodycolors to what they were set to last. Why don’t you just set the bodycolors directly using PlayerID?
When the player dies they will keep the color becuase im saving it in a datasore
--ServerScriptService
local DataStore = game:GetService("DataStoreService")
local Data = DataStore:GetDataStore("PlayerColor")
game.ReplicatedStorage.SaveColors.OnServerEvent:Connect(function(plr ,ID, a,R,G,B)
local Table = {R,G,B}
print(Table)
Data:SetAsync(ID, Table)
end)