Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make the color change for the server and other players instead of only local?

Hey scriptinghelpers, how do I make this work for the server and other players. Right now it only changes color for the player with the tool, when I want it to change color for the whole server and other players. Thanks for the help in advance. I appreciate it. I'm only here to learn.

This is a LocalScript inside of a Handle(Part) inside of a Tool.

local player = nil
local character = nil
local handle = script.Parent
local tool = handle.Parent
local brickcolorvalue = game:GetService("ReplicatedStorage"):FindFirstChildWhichIsA("BrickColorValue")
function theplayer()
	if game:GetService("Players"):GetPlayerFromCharacter(tool.Parent) ~= nil then
		player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
		character = tool.Parent
	end
	if tool.Parent:IsA("Backpack") then
		player = tool.Parent.Parent
		character = tool.Parent.Parent.Character
	end
end
theplayer()
tool:GetPropertyChangedSignal("Parent"):Connect(theplayer)
function color()
	handle.BrickColor = brickcolorvalue.Value
end
color()
brickcolorvalue:GetPropertyChangedSignal("Value"):Connect(color)

4 comments

1

LocalScripts only affect the client (ie. the player with the tool). You need to use a server 'Script' to affect the entire server.

0

Yeah, I already tried using this as a "Script" before I posted this question and it didn't work. I don't get any output either.

1

No need to use remotes for this. Change it on the server and on the client, revert it to how it's suppose to be

0

I don't really understand. I had to take a break from this script it was frustrating me. I'm going to continue testing now though, I'll get back to you guys. Sorry for the late response!

1 answer

You need to use a RemoteEvent. Have a RemoteEvent named anything you like ready in ReplicatedStorage... in this case I'll just leave it as its default name "RemoteEvent".

function color()
 
game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent"):FireServer(brickcolorvalue.Value,handle)

end

In another ServerScript, parented in ServerScriptService

game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent").OnServerEvent:Connect(function(player,color,handle)

    handle.BrickColor = color
    
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.