Script keeps on Firing Bindable Event

Hello, I’m new to events and have a hard time understanding them. Currently I am using a BindableEvent and I’m trying to fire an event when my loading screen has finished loading or has been skipped and when thats done, a different local script receives the event and should start a function. For some reason it doesnt work, I added a print after the event has been fired and received and from what the output shows me the event keeps on getting fired and then keeps on getting received but even though, the function doesnt start. Both scripts are local scripts, here is my code

Local script 1 “Loading Screen Script”

This right here is the code that is responsible for skipping the loading screen

userinputservice.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.F and Frame.BackgroundTransparency == 0 then
		print("skipped")
		Skipped = true
		TipSound.Parent = workspace.UnusedSounds
		TipScript.Enabled = false
		sound2.Volume = 0.5
		sound1.Volume = 0.5
		LoadS.Playing = false
		EnableMovement()
		while Skipped == true do
			for i = 1,100 do
				Frame.BackgroundTransparency += 0.01
				LoadingText.TextTransparency += 0.01
				NumberText.TextTransparency += 0.01
				LoadingImage.ImageTransparency += 0.01
				Tiptext.TextTransparency +=0.01
				Skip.TextTransparency +=0.01
				wait(0.01)
			end
			
			
			wait(1)
			ui:Destroy()
			Event:Fire()
			print("event fired")
			script.Enabled = false
		end
	end
end)

While this code below is for when the loading has concluded

while LoadingEnded == true do
	sound2.Volume = 0.5
	sound1.Volume = 0.5
	LoadS.Playing = false
	TipSound.Parent = workspace.UnusedSounds
	TipScript.Enabled = false
	
	
	
	for i = 1,100 do
		Frame.BackgroundTransparency += 0.01
		LoadingText.TextTransparency += 0.01
		NumberText.TextTransparency += 0.01
		LoadingImage.ImageTransparency += 0.01
		Tiptext.TextTransparency +=0.01
		Skip.TextTransparency +=0.01
		wait(0.01)
	end
	
	
	EnableMovement()
	wait(1)
	ui:Destroy()
	Event:Fire()
	print("event fired")
	script.Enabled = false
end

Local Script 2 “Info Script”

Below is the part of the script responsible for playing the functions and showing the Gui.

local function PlayGui()
	Appear()
	TextShow()
	Disappear()
end

Event.Event:Connect(PlayGui)

I know that the scripts are quite janky but thats because they’re kind of old.

The Loading Screen Local Script 1 is placed inside ReplicatedFirst,
The Info Script Local Script 2 is a child of an InfoGui inside the StarterGui,
The Remote Event is called “InfoEvent” and it is placed inside ReplicatedStorage.

I truly have no idea what I’m doing wrong and hoping someone will reply,
any help will be greatly appreciated,
Thank you for your time.

1 Like

I have found the error, it was pretty dumb of me i have to say.

The script below has the Event:Fire() inside of a while true loop!

userinputservice.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.F and Frame.BackgroundTransparency == 0 then
		print("skipped")
		Skipped = true
		TipSound.Parent = workspace.UnusedSounds
		TipScript.Enabled = false
		sound2.Volume = 0.5
		sound1.Volume = 0.5
		LoadS.Playing = false
		EnableMovement()
		while Skipped == true do
			for i = 1,100 do
				Frame.BackgroundTransparency += 0.01
				LoadingText.TextTransparency += 0.01
				NumberText.TextTransparency += 0.01
				LoadingImage.ImageTransparency += 0.01
				Tiptext.TextTransparency +=0.01
				Skip.TextTransparency +=0.01
				wait(0.01)
			end
			
			
			wait(1)
			ui:Destroy()
			Event:Fire()
			print("event fired")
			script.Enabled = false
		end
	end
end)

Simply replacing the While true loop with a if … then resolves the issue.

userinputservice.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.F and Frame.BackgroundTransparency == 0 then
		print("skipped")
		Skipped = true
		TipSound.Parent = workspace.UnusedSounds
		TipScript.Enabled = false
		sound2.Volume = 0.5
		sound1.Volume = 0.5
		LoadS.Playing = false
		EnableMovement()
    

		if Skipped == true then
			for i = 1,100 do
				Frame.BackgroundTransparency += 0.01
				LoadingText.TextTransparency += 0.01
				NumberText.TextTransparency += 0.01
				LoadingImage.ImageTransparency += 0.01
				Tiptext.TextTransparency +=0.01
				Skip.TextTransparency +=0.01
				wait(0.01)
			end
			
			
			wait(1)
			ui:Destroy()
			Event:Fire()
			print("event fired")
			script.Enabled = false
		end
	end
end)

Or you could also place the Event in a different spot outside the loop!

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