First off, I'll share my scripts for you to understand a little better.
Client:
local event = game.ReplicatedStorage.Events.HackerChangeColor local button = script.Parent local value = script.Parent.Parent.HackerLightEnter button.MouseButton1Click:Connect(function() event:FireServer(value) end)
Server:
local event = game.ReplicatedStorage.Events.HackerChangeColor event.OnServerEvent:Connect(function(plr, value) for i, v in pairs(workspace:GetChildren()) do if v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("MeshPart") then if v.Material == Enum.Material.Neon then v.BrickColor = BrickColor.new(value.text) end end end end)
In this case, I'm attempting to send the instance known as 'value' from a LocalScript to a Server script. For some reason this isn't working, and I'd like some advice or anything really as to how I can fix this. If you need more detail, please say so, this is one of my first posts so.
you need to have the fireserver event for the remote function like this
local script
game.ReplicatedStorage.RemoteEvent:FireServer(value)
and inside your server script you need to have it like this
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,value)
Hopefully this helped
Fixed! I can't edit the properties of a variable sent from the client to the server, which is what I was trying to do on line 7
v.BrickColor = BrickColor.new(value.text)
I fixed this by making the 'value' variable inside of the LocalScript From this:
local value = script.Parent.Parent.HackerLightEnter
To this:
local value = script.Parent.Parent.HackerLightEnter.Text
Meaning the code that works would be: SERVER:
local event = game.ReplicatedStorage.Events.HackerChangeColor event.OnServerEvent:Connect(function(plr, value) for i, v in pairs(workspace:GetChildren()) do if v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("MeshPart") then if v.Material == Enum.Material.Neon then v.BrickColor = BrickColor.new(value) end end end end)
CLIENT:
local event = game.ReplicatedStorage.Events.HackerChangeColor local button = script.Parent local value = script.Parent.Parent.HackerLightEnter.Text button.MouseButton1Click:Connect(function() event:FireServer(value) end)