✓ Accepted answer
I suggest you should read up on RemoteEvents, just because you change a LocalScript to Server, doesn't mean it will always work. I will provide links at the end.
Setting up:
- Create a RemoteEvent, place it within' ReplicatedStorage. Name it what you wish.
- Place a LocalScript within' the button (assuming it's a Text/Image Button).
- Place a ServerScript within' ServerScriptService.
Understanding FilterEnabled:
FilteringEnabled is a way to prevent exploiters replicating their client onto the server without the use of Events. Do keep in mind, as enabling it may prevent exploiters, it will also prevent any client replicating over, meaning you have to send information from Client to Server if you wish to replicate things through.
Understanding RemoteEvents:
There are a lot of events in which can help you replicate over to server, but most common being RemoteEvents. Here you can send information from Client to Server to allow things to replicate over.
The fault in your code:
You have tried using a ServerScript to activate something which is on the Client, this will not work and has to be through the client. This means will we have to use RemoteEvents to fire information over.
New code, explained:
Assuming you've done the setting up correctly, you can now start to place in your code.
LocalScript
local RS = game:GetService('ReplicatedStorage')
local Player = game.Players.LocalPlayer
local Button = script.Parent
local ColorValue = Button:WaitForChild('Color')
Button.MouseButton1Down:Connect(function()
RS:WaitForChild('RemoteEvent'):FireServer(ColorValue.Value)
end)
ServerScript
local RS = game:GetService('ReplicatedStorage')
local Remote = RS:WaitForChild('RemoteEvent')
Remote.OnServerEvent = function(Player, ColorValue)
local Character = Player.Character or Player.CharacterAdded:Wait()
Character.ChestColor1.BrickColor = BrickColor.new(ColorValue)
end
Summary:
You can learn more about RemoteEvents by clicking on the word link.
If you are still stuck or get any errors please feel free to add my Discord: Josh K#2740
3 comments
It depends on a lot of factors right now. First, what is the button, and second, what type of script is this. Well only 2 but still.
Please read up on the Remote Events/Functions tutorial https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
Your first script was fine. The second script had issues. Your problem is that you need to only use LocalPlayer with local scripts, thus requiring you to use Remote Events and/or Remote Functions