Could i connect two localscripts?

Could i connect two local scripts? is that possible?

1 Like

Yes it is with BindableEvents and BindableFunctions. For more specification, BindableEvents would send information to another local script with no return and BindableFunctions would be used if you want to send information to a local script and have something get returned.

4 Likes

Wow!! i didn’t know that, thanks you so much! :slight_smile:

2 Likes

Hello! I read the documentation and did everything at the bottom but I can’t connect two localscripts, how can I do it? i want to use it here

listener code (another) localscript:

local BindableEvent = game.Workspace:WaitForChild("BlindableEvent")

game.Workspace.Tool.Handle.Touched:Connect(function() --tool touched
	-- Defense anim F key
	UserInputService.InputBegan:Connect(function(input, gameProccesedEvent)
		if input.KeyCode == Enum.KeyCode.F then
			print("Playing defense animation! done.")
			local playAnim = humanoid:LoadAnimation(defanim)
			playAnim:Play()
			script.DefAnim:FireServer()
			BindableEvent.Event:Connect(function()
				print("bindable event is done.")
			end)
		end
	end)

fire code (localscript):

local BindableEvent = game.Workspace:WaitForChild("BlindableEvent")

wait(0.5)

local function DecreaseLight()

print("Bindable event fired")

intvalue.Value -= 20

BindableEvent:Fire()

end
1 Like

Are you running your DecreaseLight function further down in your code? The bindable event won’t fire unless the function containing the code to fire the event is ran.

3 Likes