As the title says, the remote event isn’t properly working. I’m trying to make a script where whenever I hit a button the part changes to blue and after 5 seconds the part changes to red only to me (the client). Everything works fine the first time but when I try clicking the button again the remote event just doesn’t work again. Here are the scripts:
LocalScript
local partColor = part.Color
local tf = true
script.Parent.Activated:Connect(function()
if tf == true then
game:GetService("ReplicatedStorage").RemoteEvent:FireServer()
wait(5)
part.Color = partColor
tf = false
end
end)
EventScript
local RE = game:GetService("ReplicatedStorage").RemoteEvent
RE.OnServerEvent:Connect(function(player)
if player then
part.Color = Color3.fromRGB(0, 166, 255)
end
end)
This is happening because tf’s value is set to false which won’t make it work anymore after the first activation. This happens because the script disables it at the end and doesn’t reactivate it at the next click.
EmilyBendsSpace’s solution should work perfectly fine. mark her reply as the solution if it works, which it should hopefully.