BindableEvent not being recieved on workspace serverscript

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

  1. What do you want to achieve? I want the script (located in workspace) to receive the BindableEvent.

  2. What is the issue? The BindableEvent is not being received or registered (see bottom of code). None of the print statements are firing.

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local ServerStorage = game:GetService('ServerStorage')

local corner1 = Vector3.new(script.Parent.Position + (script.Parent.Size/2))  -- Replace x1, y1, z1 with actual coordinates
local corner2 = Vector3.new(script.Parent.Position - (script.Parent.Size/2))  -- Replace x1, y1, z1 with actual coordinates
local ballDetectionRegion = Region3.new(corner1, corner2)

local runningThread = nil

-- Reference to the ball
local ball = workspace:WaitForChild("SoccerBall")

-- Predetermined function to be called
function onBallDetected()
	print("Scored!!")
end

-- Function to check if the ball is inside the Region3
function isBallTouching(ball : BasePart, targetChar)
	
	if not(targetChar) then
		return
	end
	
	ball.Touched:Connect(function(hit)
		if hit.Parent == targetChar then
			return true
		end
	end)
	
	return false
end

function storage(ball)
	local overlaparams = OverlapParams.new()
	local parts = workspace:GetPartBoundsInBox(CFrame.new(script.Parent.Position), script.Parent.Size, overlaparams)
	
	return (table.find(parts, ball) ~= nil)
end

function onReset()
	print('onreset called')
	while true do
		if storage(ball) == true then
			onBallDetected(ball.PlayerWhoLastHit.Value)
			break  -- Stop the loop once the ball is detected inside the Region3
		end
		task.wait(0.05)  -- Check periodically (adjust the interval as needed)
	end
end

ReplicatedStorage.Bindables:WaitForChild("NewRoundBindable").Event:Connect(function()
	print("EZPZ")
	if (runningThread) then
		coroutine.yield(runningThread)
	end
	
	runningThread = coroutine.create(function(...) 
		print('coro ran')
		onReset()
	end)
	
	print('coro ran 2')
	coroutine.resume(runningThread)
end)

ReplicatedStorage.Bindables:WaitForChild("NewRoundBindable").Event:Connect(function()
	task.wait(3.1) --Wait for the ball to get cleared
	
	if (runningThread) then
		coroutine.yield(runningThread)
	end

	runningThread = coroutine.create(function(...) 
		onReset()
	end)

	coroutine.resume(runningThread)
end)

Can we see the script from where the BindableEvent is being fired from?

If the one who sends is a Local Script, then you can’t use BindableEvents, you’d have to use a RemoteEvent

1 Like

It is being sent from a serverscript in serverscriptservice:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService('ReplicatedStorage')

local INTERMISSION_TIME = 3

game:GetService('Players').PlayerAdded:Connect(function(player)
	task.wait(2)
	print('firing')
	ReplicatedStorage.Bindables.NewRoundBindable:Fire()
end)


--Do more shit
ReplicatedStorage.Bindables.GameOver.Event:Connect(function()
	for i = INTERMISSION_TIME, 0, -1 do
		task.wait(1)
		print("Intermission:", i)
	end
	
	ReplicatedStorage.Bindables.NewRoundBindable:Fire()
end)
1 Like

The issue has been resolved. Thank you guys

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