How to call a function in a Script from another Script?

I am trying to make one script call a function in another script. Both scripts are global scripts and non of them is a local script, using a remote event/function is not an option.
Yes, I know about module scripts, but they don’t fit what I need as the calling script is constantly being cloned forever (with delay between cloning of course).
I also don’t want to use _G and Shared because it would open a huge backdoor for exploiters, which I of course don’t want at any cost.

Any ideas how I may be able to make it work?

.

.

The caller script:

local reciever = game.Workspace.Conveyor:WaitForChild("Script")

function InterscriptCommunication_Test_Caller()
	print("before calling")
	
	-- call the function in the reciever script, sending to it script.Parent as an argument
	
	print("after calling")
end

while wait(1) do
	InterscriptCommunication_Test_Caller()
end

.

.

The reciever script:

local timesCalled = 0

function InterscriptCommunication_Test_Reciever(item:BasePart)
	print("recieved")
	timesCalled += 1
	return timesCalled
end
1 Like

Could you share both scripts and the function?

Yes, of course. I’ve added it to the post

You could use a blindableFunctions

local reciever = game.Workspace.Conveyor:WaitForChild("Script")
local blindableFunction = --any path

function InterscriptCommunication_Test_Caller()
	print("before calling")
	
	local timesCalled = blindableFunction.Invoke(script.Parent)
	
	print("after calling")
end

while wait(1) do
	InterscriptCommunication_Test_Caller()
end

Other script

local timesCalled = 0
local blindableFunction = --any path

function InterscriptCommunication_Test_Reciever(item:BasePart)
	print("recieved")
	timesCalled += 1
	return timesCalled
end

blindableEvent.OnInvoke = InterscriptCommunication_Test_Reciever
1 Like

It works now, thanks you very much

1 Like