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