Remote Event not firing?

Hello, so basically I have a problem with a remote event not firing. The thing is the remote event fires in Roblox studio but not In Roblox probably because Roblox is 2x faster than Roblox studio. Because Roblox Studio is just a simulation of Roblox’s servers when playtesting.

Here is the script:

-- Player Service

local Players = nil

-- Main Stuff
local RemoteEvent = game.ReplicatedStorage.SideBar.GivePlayerToServer
local level = game.ReplicatedStorage:WaitForChild("GeneratedLevels"):GetChildren()
local studs = 0
local endLevel = game.ReplicatedStorage.End
-- Wait Time Variables
local WaitTime1 = os.time() + 2
local WaitTime2 = os.time() + 2
local ColorTable = {}

--repeat wait(1) until #game.Players:GetPlayers() <= 1
--repeat wait(1) until localplayer
wait(WaitTime1 - os.time())
while wait(1) do
	wait()
	local ColorTable = {}
	local SizeTable = {}
	for count = 1, 6 do
		for i, placeHolder in pairs(game.Workspace.PlaceHolders:GetChildren()) do
			local chosenLevel = level[math.random(1, #level)]:Clone()
			print(chosenLevel.Name)
			table.insert(SizeTable, UDim2.new(chosenLevel.SizeInfo.Size.Value,chosenLevel.SizeInfo.Size2.Value,chosenLevel.SizeInfo.Size3.Value,chosenLevel.SizeInfo.Size4.Value))
			table.insert(ColorTable, Color3.new(chosenLevel.ColorBar.Value/250,chosenLevel.ColorBar2.Value/250,chosenLevel.ColorBar3.Value/250))
			chosenLevel.PrimaryPart = chosenLevel.Floor
			chosenLevel:SetPrimaryPartCFrame(CFrame.new(placeHolder.Position)+ Vector3.new(studs, 0, 0))
			studs = studs - chosenLevel.studs.Value

			chosenLevel.Parent = game.Workspace.currentLevels
		end
	end

	local endLevelClone = endLevel:Clone()
	endLevelClone.PrimaryPart = endLevelClone.Floor
	endLevelClone:SetPrimaryPartCFrame(CFrame.new(game.Workspace.PlaceHolders.Floor.Position)+ Vector3.new(studs, 0, 0))
	endLevelClone.Parent = game.Workspace.currentLevels	
	print("Be savage")
	wait(WaitTime2 - os.time())
	for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
		wait()
		if (player) then
			game.ReplicatedStorage:WaitForChild("SideBar"):WaitForChild("GiveColoursToClient"):FireClient(player, ColorTable, SizeTable)
		end
	end

	local minutes = 6
	local seconds = 0

	local minutesVal = game.ReplicatedStorage:WaitForChild("TimerVal"):WaitForChild("minutesVal")
	minutesVal.Value = minutes

	local secondsVal = game.ReplicatedStorage:WaitForChild("TimerVal"):WaitForChild("secondsVal")
	secondsVal.Value = seconds

	local timer = game.ReplicatedStorage.Timer


	repeat
		if seconds <= 0 and secondsVal.Value <= 0 then
			minutes = minutes - 1
			seconds = 59

			minutesVal.Value = minutesVal.Value - 1
			secondsVal.Value = 59
		else
			seconds = seconds - 1
			secondsVal.Value = secondsVal.Value - 1
		end

		if seconds <= 9 then

			timer.Value = tostring(minutes)..":0"..tostring(seconds) else

			timer.Value = tostring(minutes)..":"..tostring(seconds)
		end

		wait(game.Workspace.Values.WaitSpeed.Value)

	until minutes <= 0 and seconds <= 0

	if minutes <= 0 and seconds <= 0 then		
		-- Claimed Value
		for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
			if (player) then
				player.ClaimedFolder.Claimed.Value = false
			end
		end
		-- Rep Values for local Buttons
		game.ReplicatedStorage.ShopEvents.LocalButtons.invisibilityButton.Value = false
		game.ReplicatedStorage.ShopEvents.LocalButtons.BunnyHopButton.Value = false
		game.ReplicatedStorage.ShopEvents.LocalButtons.FogButton.Value = false
		game.ReplicatedStorage.ShopEvents.LocalButtons.HighSpeedButton.Value = false
		game.ReplicatedStorage.ShopEvents.LocalButtons.LowGravityButton.Value = false
		game.ReplicatedStorage.ShopEvents.LocalButtons.invincibilityButton.Value = false

		-- Bought Values
		script.Parent.ShopItems.BunnyHopFolder.bought.Value = false
		script.Parent.ShopItems.invisivilityFolder.bought.Value = false
		script.Parent.ShopItems.FogFolder.bought.Value = false
		script.Parent.ShopItems.LowGravityFolder.bought.Value = false
		script.Parent.ShopItems.HighSpeedFolder.bought.Value = false
		script.Parent.ShopItems.invincibilityFolder.bought.Value = false
		-- Enabled Value example(BunnyHopEnabled)
		script.Parent.ShopItems.BunnyHopFolder.BunnyHopEnabled.Value = false
		script.Parent.ShopItems.invisivilityFolder.InvisibilityEnabled.Value = false
		script.Parent.ShopItems.FogFolder.FogEnabled.Value = false
		script.Parent.ShopItems.LowGravityFolder.LowGravityEnabled.Value = false
		script.Parent.ShopItems.HighSpeedFolder.HighSpeedEnabled.Value = false
		script.Parent.ShopItems.invincibilityFolder.invincibilityEnabled.Value = false
		-- Fog Back to normal ;)
		game.Lighting.FogEnd = 100000
		game.Lighting.FogStart = 0
		game.Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128)
		-- Gravity Back to normal ;)
		game.Workspace.Gravity = 196.2
	end

	for i, player in pairs(game.Players:GetChildren())do
		player:LoadCharacter()
		wait(.1)
		player:LoadCharacter()
	end

	game.Workspace.Values.WaitSpeed.Value = 1
	game.Workspace.Values.SpeedMultiplier.Value = 1	


	game.Workspace.currentLevels:ClearAllChildren()
	studs = 0 
end

The remote event that is not getting fired is:‘game.ReplicatedStorage:WaitForChild(“SideBar”):WaitForChild(“GiveColoursToClient”):FireClient(player, ColorTable, SizeTable)’

2 Likes

I think the problem is that when you as a player join the game the ‘while wait(1) do’ is too fast and fires the event before the Roblox loading screen even finishes loading. :confused:

You haven’t used the remoteEvent at all, you only defined it.
For more defensive scripting, try using a more signal-styled coding pattern.

Currently you’re querying for a player to join instead of listening to their joins.

3 Likes

what do you mean by defined it? I used ‘:FireClient’ to fire the remote event to the client and then change some UI.

here is the OnClientEvent local script:

-- Player
local player = game.Players.LocalPlayer
-- Variables
local frame1 = script.Parent.Main.SideBarFrame.Frame1
local frame2 = script.Parent.Main.SideBarFrame.Frame2
local frame3 = script.Parent.Main.SideBarFrame.Frame3
local frame4 = script.Parent.Main.SideBarFrame.Frame4
local frame5 = script.Parent.Main.SideBarFrame.Frame5
local frame6 = script.Parent.Main.SideBarFrame.Frame6

game.ReplicatedStorage.SideBar.GiveColoursToClient.OnClientEvent:Connect(function(ColorTable, SizeTable)
	print("Checking Remote event is Fired")
	wait()
	function Refresh1()
		frame1.BackgroundColor3 = ColorTable[1]
	end
	
	function Refresh2()
		frame2.BackgroundColor3 = ColorTable[2]
	end
	
	function Refresh3()
		frame3.BackgroundColor3 = ColorTable[3]
	end
	
	function Refresh4()
		frame4.BackgroundColor3 = ColorTable[4]
	end
	
	function Refresh5()
		frame5.BackgroundColor3 = ColorTable[5]
	end
	
	function Refresh6()
		frame6.BackgroundColor3 = ColorTable[6]
	end
	
	repeat
		wait()
		Refresh1()
		Refresh2()
		Refresh3()
		Refresh4()
		Refresh5()
		Refresh6()
	until script.Disabled == true
end)

--for index, value in ipairs(ColorTable) do
	--frame1.BackgroundColor3 = value
	--print(index .. " = " .. tostring(value))
--end

The thing is that the main script is a server script, and to get the player will be trickier than I thought, my game is like a round generating epic games/tower of hell kind.

I searched (ctrl + f) through the script right now, there’s no :FireClient method being used.

this is right from the script.:confused:

There’s fundamentally something incorrect if you need to wait for something that you’re not instancing through your script.

1 Like

I get what you mean, but how would I fix that? Do I need to change the whole script?