RemoteEvent cloning values when its not supposed to

Hello, I am trying to create a remoteevent for updating values on the server side after being changed on the local side. For some reason, it seems to be cloning these events and causing the value to be changed multiple times on the server side, even if its not the desired value. Thanks in advance!

function UpdateVals(itemName, newValue)		--update values
	values[itemName].Value = newValue
	handler:FireServer('UpdateVals', itemName, newValue)
end

Can you please provide more of your code?
(For example, what calls UpdateVals, and the server side code that is outputting Map On etc.

Sure thing.

Local Script:

lightsMenu.Map.MouseButton1Click:Connect(function()		--map lights
	local itemName = "Map"
	values.CurrentScreen.Value = itemName
	values.LastScreen.Value = "LightsMenu"
	script.Parent.Ribbon.Back.Visible = true
	for i,v in pairs(script.Parent.Content:GetDescendants()) do
		if v:IsA("Frame") and v.Name ~= "ToggleMenus" then
			v.Visible = false
		end
	end
	selectionOnOff.Visible = true
	selectionOnOff.On.MouseButton1Click:Connect(function()
		UpdateVals(itemName, "On")
		Back("LightsMenu")
	end)
	selectionOnOff.Off.MouseButton1Click:Connect(function()
		UpdateVals(itemName, "Off")
		Back("LightsMenu")
	end)
end)

function UpdateVals(itemName, newValue)		--update values
	values[itemName].Value = newValue
	handler:FireServer('UpdateVals', itemName, newValue)
end

Server side remote event

wait(.5)

F = {}
local player = nil
local carVals = script.Parent.Parent.Values

F.UpdateVals = function(itemName, newValue)
	print (itemName, newValue)
	if itemName == "Work" then
		if newValue == "On" then
			carVals.Lights.WorkLight.Value = true
		elseif newValue == "Off" then
			carVals.Lights.WorkLight.Value = false
		end
	elseif itemName == "Map" then
		if newValue == "On" then
			carVals.Lights.Map.Value = true
		elseif newValue == "Off" then
			carVals.Lights.Map.Value = false
		end
	end
	print ("---------------------------------------------------------")
end


script.Parent.OnServerEvent:connect(function(pl,Fnc,...)
	player = pl
	F[Fnc](...)
end)

I think I found a workaround which doesn’t require the updatevals function and I am no longer having this issue, thanks for your help.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.