Hey everyone reading this!

I am having problems with a RemoteEvent not being able to fire server --> client.

Server Script:

local debounce = false

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	print("No Humanoid")
	
	if debounce == false then
		debounce = true
		if humanoid then
			print("Humanoid")
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			
			script.Parent:WaitForChild("Triggered"):FireClient(player)
		end
	end
end)

Local Script:

local uIS = game:GetService("UserInputService")
local looping = true

while looping do
	wait()
	script.Parent:WaitForChild("Triggered").OnClientEvent:Connect(function(player)
		looping = false
		script.Parent.CanCollide = false
		print("Vault Tutorial Triggered")
		local player = game.Players.LocalPlayer
		local tutorialGui = player.PlayerGui:WaitForChild("TutorialGui")
		local autoMove = player.PlayerScripts:WaitForChild("AutoMove").Disabled
		local vault = tutorialGui:WaitForChild("Vault") 
		
		vault.Visible = true
		autoMove = true
		
		uIS.InputBegan:Connect(function(input, gameProcessed)
			if input.KeyCode == Enum.KeyCode.KeypadEnter then
				autoMove = false
				vault.Visible = false
			end
		end)
	end)
end

I'm not getting any errors, but the script inside of the OnClientEvent doesn't play.

Thank you for reading! Any help is appreciated!

6 comments

0

You aren't setting the debounce variable back to false, so it won't pass more than once. That is unless you intend to do so.

0

My intention with the debounce is to keep a player from using the trigger more then once. Thanks for replying anyways.

0

I would also not recommend looping event listeners. Every time the loop iterates it creates a new event listener, so you are going to have an incredibly unnecessary number of event listeners.

0

What are the prints after you run once?

0

I ran it, here are the prints:

0

 17:27:04.417 No Humanoid - Server - VaultScriptServer:5   17:27:04.417 Humanoid - Server - VaultScriptServer:10   17:27:04.517 ? No Humanoid (x8) - Server - VaultScriptServer:5