I need a script to put inside a button, that sets the button’s background color (locally) to the player’s torso color (torso or uppertorso, so it works on r6 and r15), any help is appreciated
If you want it to be visible to everyone, you’ll need to use a RemoteEvent
whenever you need to change it.
It could look something like this:
Client
local replicatedStorage = game:GetService("ReplicatedStorage")
local remote = replicatedStorage:WaitForChild("RemoteEvent") --// This can be named and placed wherever you want. You just have to change it here
remote:FireServer(script.Parent.BackgroundColor3)
Server
local replicatedStorage = game:GetService("ReplicatedStorage")
local remote = replicatedStorage:WaitForChild("RemoteEvent") --// This can be named and placed wherever you want. You just have to change it here
remote.OnServerEvent:Connect(function(player, buttonColor)
if not player then return end
local character = player.Character or player.CharacterAdded:Wait()
if character then
if character:FindFirstChild("BodyColors") then
character:FindFirstChild("BodyColors").TorsoColor3 = buttonColor
else
character.Torso.Color = buttonColor
end
end
end)
1 Like
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local torso:Part = char:WaitForChild("Torso")
local button = script.Parent
torso.BackgroundColor3 = torso.Color
hi, it has to be local sided, so just needs to be put inside a button
Then just use all of the code inside of the remote event in the local script when you need to.
This should be simple enough to implement, you can rely on the BodyColors
instance inside a player’s character to get their torso colour (which will work with both R6 and R15), then set that to the background colour
Make sure to use a LocalScript not a Script