Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

RemoteEvent map change wont work?

So, I've been trying to make it so that a trainer can open a gui and then press a button to swap the map on my game. My game is FE tho, so I had to use remoteevents to do it. The issue is, whenever I try to switch the map, it doesn't work.

Server Code:

game.ReplicatedStorage.MapChange.OnServerEvent:Connect(function(plr,mapName,teams)
	if teams then
		for i,v in pairs(game.ServerStorage.Teams:GetChildren()) do
			if v.Name == "Red" or v.Name == "Blue" then
				v.Parent = game.Teams
			end
		end
	else
		for i,v in pairs(game.Teams:GetChildren()) do
			if v.Name == "Red" or v.Name == "Blue" then
				v.Parent = game.ServerStorage.Teams
			end
		end
	end
	local program = workspace.Program:FindFirstChildOfClass("Model")
	if program ~= nil then
		program.Parent = game.ServerStorage.Programs
	end
	program = game.ServerStorage.Programs[mapName]
	program.Parent = workspace.Program
end)

Client Code:

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.MapChange:FireServer("Obby",false) --This would change depending on the map
end)

Am I doing anything wrong here?

1 answer

It doesn’t look like you set a variable for teams in the server script yet you called it. Try doing teams = game.Serverstorage:FindFirstChild(“Teams”) before the whole server script.

2 comments

0

Teams is his third argument in the event. It's provided false on Client firing.

0

Sorry^ couldn’t see it in mobile...

This discussion is preserved as it was. New answers, comments, and votes are closed.