local rs = game:GetService("ReplicatedStorage")
local startergui = game:GetService("StarterGui")
local colorbuttons = startergui.ScreenGui.colors
local buttons = {colorbuttons.Red, colorbuttons.Green, colorbuttons.Blue}
local colors = {"Really red", "Lime green", "Really blue"}
for i, v in pairs(buttons) do
v.MouseButton1Down:Connect(function()
rs.colorevent:FireServer(colors[i])
end)
end
rs.colorevent.OnClientEvent:Connect(function(plr, message)
startergui.ScreenGui.colors.Visible = false
end)
and the server script.
local rs = game:GetService("ReplicatedStorage")
local ss = game:GetService("ServerStorage")
rs.colorevent.OnServerEvent:Connect(function(plr, color)
print(plr.Name.." selected "..color.." color")
local brick = ss:FindFirstChild(plr.Name.."_2")
brick.BrickColor = BrickColor.new(color)
rs.colorevent:FireClient(plr)
end)
That’s all, also I did check and remotevent is in ReplicatedStorage, and the player’s rock is in ServerStorage
try doing this and move it to the bottom of the script. I think I had trouble with this in the past and this fixed it for me. But you will need to add a cooldown, so it doesn’t fire the remote event a million times (I don’t think this is a very good script but it might fix the problem)
while true do
for i, v in pairs(buttons) do
v.MouseButton1Down:Connect(function()
rs.colorevent:FireServer(colors[i])
end)
end
task.wait()
end
Yea, that looks like it would cause more problems. Because you’re continually creating new connections each time. You really just need to do Connect once for each button.
does it shows any error? i fix a lot of my codes when an error throws, btw you should print() on all functions, just for knowing when does the code stops working