My Event does not fire in game

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want the script to both work in Roblox and Roblox Studio

  1. What is the issue? Include screenshots / videos if possible!

In Roblox Studio I don’t know why sometimes the script works and it fires the event for every clients but in the regular Roblox game It just does not work it does not fire the event

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I tried remaking my script while using other loops instead of with the changed function but nothing seems to work

-- the Server Script
 


game.ReplicatedStorage.Values.Trash.Changed:Connect(function()
	if game.ReplicatedStorage.Values.Trash.Value <= 0 then
		print('trash done')
		wait('GAME STARTED')
		local ts = game.TweenService:Create(game.Lighting, TweenInfo.new(3), {ClockTime = 0})
		ts:Play()
		workspace.DummySpecial.HumanoidRootPart.Anchored = false
		local anim = workspace.DummySpecial.Humanoid:LoadAnimation(script.Animation)
		anim:Play()
		workspace.DummySpecial.HumanoidRootPart["Bone Cracks 4 (SFX)"]:Play()

		anim.Ended:Wait()
		workspace.DummySpecial:Destroy()

		ts.Completed:Wait()
		workspace["light pole"].light.Light.Enabled = true
		game.ReplicatedStorage.StartGame:FireAllClients() -- fire 
		wait(2)
		-- Spawn Mobs
		local playerCount = #game.Players:GetPlayers()

		game.Lighting.nighttime.Enabled = true

		-- Chances

		print(playerCount .. ' player')

		game.ReplicatedStorage.Values.PlayersNb.Value = playerCount

		if playerCount == 1  then
			--Guest 666
			game.ReplicatedStorage.Values.Mobs.Guest666.Chance.Value = '9'
			game.ReplicatedStorage.Values.Mobs.Guest666.Time.Value = '45'
			--Tripmine
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.Chance.Value = '35'
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.TimeMax.Value = '15'


			--Builderman

			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Speed.Value = '3'

			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Speed.Value = '3'

			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Speed.Value = '3'



			--Noob

			game.ReplicatedStorage.Values.Mobs.Noob.Chance.Value = '10'
			game.ReplicatedStorage.Values.Mobs.Noob.Wait.Value = '35'

			--Girl

			game.ReplicatedStorage.Values.Mobs.Acorn.Chance.Value = '5'

			--Bacon

			game.ReplicatedStorage.Values.Mobs.Bacon.Chance.Value = '18'


			--diamond

			game.ReplicatedStorage.Values.Mobs.Diamond.Chance.Value = '7'

		elseif playerCount == 2  then
			--Guest 666
			game.ReplicatedStorage.Values.Mobs.Guest666.Chance.Value = '9'
			game.ReplicatedStorage.Values.Mobs.Guest666.Time.Value = '40'
			--Tripmine
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.Chance.Value = '32.5'
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.TimeMax.Value = '15'


			--Builderman

			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'

			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'

			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'



			--Noob

			game.ReplicatedStorage.Values.Mobs.Noob.Chance.Value = '10'
			game.ReplicatedStorage.Values.Mobs.Noob.Wait.Value = '32'

			--Girl

			game.ReplicatedStorage.Values.Mobs.Acorn.Chance.Value = '5'

			--Bacon

			game.ReplicatedStorage.Values.Mobs.Bacon.Chance.Value = '16'


			--diamond

			game.ReplicatedStorage.Values.Mobs.Diamond.Chance.Value = '6'
		elseif playerCount == 3  then
			--Guest 666
			game.ReplicatedStorage.Values.Mobs.Guest666.Chance.Value = '9'
			game.ReplicatedStorage.Values.Mobs.Guest666.Time.Value = '40'
			--Tripmine
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.Chance.Value = '32'
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.TimeMax.Value = '15'


			--Builderman

			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'

			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'

			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'



			--Noob

			game.ReplicatedStorage.Values.Mobs.Noob.Chance.Value = '10'
			game.ReplicatedStorage.Values.Mobs.Noob.Wait.Value = '32'

			--Girl

			game.ReplicatedStorage.Values.Mobs.Acorn.Chance.Value = '5'

			--Bacon

			game.ReplicatedStorage.Values.Mobs.Bacon.Chance.Value = '16'


			--diamond

			game.ReplicatedStorage.Values.Mobs.Diamond.Chance.Value = '6'
		elseif playerCount == 4  then
			--Guest 666
			game.ReplicatedStorage.Values.Mobs.Guest666.Chance.Value = '9'
			game.ReplicatedStorage.Values.Mobs.Guest666.Time.Value = '35'
			--Tripmine
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.Chance.Value = '30'
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.TimeMax.Value = '10'


			--Builderman

			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'

			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'

			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Max.Value = '85'
			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Speed.Value = '2.5'



			--Noob

			game.ReplicatedStorage.Values.Mobs.Noob.Chance.Value = '10'
			game.ReplicatedStorage.Values.Mobs.Noob.Wait.Value = '32'

			--Girl

			game.ReplicatedStorage.Values.Mobs.Acorn.Chance.Value = '5'

			--Bacon

			game.ReplicatedStorage.Values.Mobs.Bacon.Chance.Value = '12'


			--diamond

			game.ReplicatedStorage.Values.Mobs.Diamond.Chance.Value = '6'
		elseif playerCount == 5  then
			--Guest 666
			game.ReplicatedStorage.Values.Mobs.Guest666.Chance.Value = '8'
			game.ReplicatedStorage.Values.Mobs.Guest666.Time.Value = '30'
			--Tripmine
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.Chance.Value = '20'
			game.ReplicatedStorage.Values.Mobs.SubspaceTrimpmine.TimeMax.Value = '10'


			--Builderman

			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Max.Value = '75'
			workspace.Buildermans.Builderman.HumanoidRootPart.BuilderScript.Speed.Value = '1'

			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Max.Value = '75'
			workspace.Buildermans.Builderman2.HumanoidRootPart.BuilderScript.Speed.Value = '1'

			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Max.Value = '75'
			workspace.Buildermans.Builderman3.HumanoidRootPart.BuilderScript.Speed.Value = '1'



			--Noob

			game.ReplicatedStorage.Values.Mobs.Noob.Chance.Value = '10'
			game.ReplicatedStorage.Values.Mobs.Noob.Wait.Value = '25'

			--Girl

			game.ReplicatedStorage.Values.Mobs.Acorn.Chance.Value = '5'

			--Bacon

			game.ReplicatedStorage.Values.Mobs.Bacon.Chance.Value = '10'


			--diamond

			game.ReplicatedStorage.Values.Mobs.Diamond.Chance.Value = '5'

		end

		game.ServerScriptService.Mobs.Guest666Spawn.Enabled = true
		game.ServerScriptService.Mobs.DiamondShapeSpawn.Enabled = true
		game.ServerScriptService.HoursPass.Enabled = true
		--
		workspace.Enemy.Girl.GirlAi.Enabled = true
		workspace["light pole"].light.Material = Enum.Material.Neon
		game.ServerScriptService.TimeValue.Enabled = true
		game.ServerScriptService.TimeValue.HouseWait.Enabled = true
		game.ReplicatedStorage.Values.GameStarted.Value = true
		workspace.Enemy.Noob.NoobAi.Enabled = true
		workspace.Enemy.Bacon.GuyAi.Enabled = true
		for _,player in ipairs(game.Players:GetPlayers()) do

			player.Character.HightLightClick.Enabled = true
			player.PlayerGui.ZoomNOut.Enabled = true
		end

		for _, descendant in pairs(game.Workspace.Doors:GetDescendants()) do
			if descendant:IsA('ClickDetector') then

				descendant.MaxActivationDistance = 8

			end
		end

		wait(2)
		workspace.Doors.DoorMain.Main.Model.Closed.muffeled:Play()



	end
		
	
	
	
end)




-- The Remote Event

replicatedStorage.StartGame.OnClientEvent:Connect(function()

	
	script.Parent.Parent.notfirstperson.Enabled = false
	
	local ts = game:GetService('TweenService'):Create(script.Parent.objectif.title,TweenInfo.new(1), {Position = UDim2.new(-1,0,0,0)})
	ts:Play()
	wait(2)
	local ts = tweenService:Create(script.Parent.GAMESTARTEDWARNING,TweenInfo.new(2), {Transparency = 1} )
	local ts2 = tweenService:Create(script.Parent.GAMESTARTEDWARNING.TextLabel,TweenInfo.new(5),  {Transparency = 1} )
	local ts3 = tweenService:Create(script.Parent.GAMESTARTEDWARNING.TextLabel2,TweenInfo.new(5),  {Transparency = 1} )
	local ts5 = tweenService:Create(script.Parent.GAMESTARTEDWARNING.Frame.UIStroke,TweenInfo.new(3),  {Transparency = 1} )
	local ts4 = tweenService:Create(workspace.CurrentCamera,TweenInfo.new(.5),  {FieldOfView = 2} )
	local ts6 = tweenService:Create(script.Parent.GAMESTARTEDWARNING.ImageLabel,TweenInfo.new(3),  {ImageTransparency = 1} )

	game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
	ui.GAMESTARTEDWARNING.Visible = true
	script["electronicpingshort.wav"]:Play()
	ts4:Play()
	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
	wait(2)
	ts5:Play()
	ts:Play()
	ts6:Play()
	ts2:Play()
	ts3:Play()
	script.Parent.Parent.FirstPerson.Enabled = true
	workspace.CurrentCamera.FieldOfView = 90
	script.Parent.Sound.Enabled = true
	game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
	plyr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, true)
	
	
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes

by the way the local script that receives the event is a local script in ''StarterGui ‘‘while the Server Script is a normal script in ;;ServerScriptService’’

2 Likes

Since this is a localscript you should use :WaitForChild() on almost everything since it isn’t guaranteed that it will be replicated to the client immediately. You should also add more debugging by printing to see where the issue is exactly occurring.

1 Like

I tried using both of the thing you said but the event only fires in Studio I used the :WaitForChild and I tried printing after every wait but its only printing in Studio

Studio
image

Roblox

1 Like

Could you switch to the client on your console to see if it is there?

1 Like

yeah ofc!

there is only the loaded print

Hmm are you firing this remote event immediately? Because if you are firing it before the local script has loaded in it will not register the event.

the remove events fires when the player finishes collecting 3 objects

can you v2 this RemotesHandler V1

Hmm could you please share the rest of the local script because something seems to be blocking the event listener itself.

yeah ofc !

local ui = script.Parent
local replicatedStorage = game:GetService(‘ReplicatedStorage’)
local tweenService = game:GetService(‘TweenService’)
local values = replicatedStorage.Values
local players = game.Players
local plyr = players.LocalPlayer

plyr.PlayerGui.GameUi.wait.Visible = true
game.Players.LocalPlayer.CharacterAdded:Wait()

plyr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
local CamIn = Instance.new(‘StringValue’)
CamIn.Name = ‘CamIn’
CamIn.Parent = plyr

local Player = game.Players.LocalPlayer
local BadgeService = game:GetService(‘BadgeService’)
replicatedStorage:WaitForChild(‘StartGame’).OnClientEvent:Connect(function()

print('nice123')
script.Parent.Parent.notfirstperson.Enabled = false

local ts = game:GetService('TweenService'):Create(script.Parent.objectif.title,TweenInfo.new(1), {Position = UDim2.new(-1,0,0,0)})
ts:Play()
wait(2)
print('nice1234')
local ts = tweenService:Create(script.Parent.GAMESTARTEDWARNING,TweenInfo.new(2), {Transparency = 1} )
local ts2 = tweenService:Create(script.Parent.GAMESTARTEDWARNING.TextLabel,TweenInfo.new(5),  {Transparency = 1} )
local ts3 = tweenService:Create(script.Parent.GAMESTARTEDWARNING.TextLabel2,TweenInfo.new(5),  {Transparency = 1} )
local ts5 = tweenService:Create(script.Parent.GAMESTARTEDWARNING.Frame.UIStroke,TweenInfo.new(3),  {Transparency = 1} )
local ts4 = tweenService:Create(workspace.CurrentCamera,TweenInfo.new(.5),  {FieldOfView = 2} )
local ts6 = tweenService:Create(script.Parent.GAMESTARTEDWARNING.ImageLabel,TweenInfo.new(3),  {ImageTransparency = 1} )

game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0
ui.GAMESTARTEDWARNING.Visible = true
script["electronicpingshort.wav"]:Play()
ts4:Play()
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
wait(2)
print('nice1235')
ts5:Play()
ts:Play()
ts6:Play()
ts2:Play()
ts3:Play()
script.Parent.Parent.FirstPerson.Enabled = true
workspace.CurrentCamera.FieldOfView = 90
script.Parent.Sound.Enabled = true
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
plyr.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, true)

end)

1 Like

A tip, use the preformatted code text next time so it is easier to read, but I see that the issue is that some stuff may not be loaded in immediately. I suggest adding :WaitForChild() for almost everything inside a local script (like replicatedStorage:WaitForChild("Values") or plr:WaitForChild("PlayerGui"):WaitForChild("GameUi"))

2 Likes

oh kk thx for the tip but i think ive found it the game.Players.LocalPlayer.CharacterAdded:Wait() may have blocked something before i removed it and now it worked perfeclty thx for the help

1 Like

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