Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there any way to send arguments from one script to another?

I want to pass down Debounces,Variables,Arugments from one script to another. The reason being is because I want all things aka the Variables,Arugments and Debounces to work in those two scripts.For Example:One person gets hit my a punch the other person gets stunned. Doing this it goes into all of there attack scripts and sets the Debounce to false so that the player is stunned. Thanks for helping me :).

2 comments

0

i think you need to use bindable events

0

What are those?

2 answers

You can use Bindable Events to transfer data between scripts of the same scope if you have FE enabled. This means that a bindable event can transfer data from server script to server script, or client script to client script. You can read about them and their more useful functions here.

Remote Events work in the same way, but allow for client to server and server to client communication. These can be intimidating at first, so I would recommend looking at the wiki page here for a very in-depth look on their exact use.

Bindable Events allows two scripts to communicate with each other. For example, with bindables, you can have two server scripts communicate and two local scripts communicate. In remote events, only server scripts and local scripts can communicate.

(both codes below are server scripts)

Sender:

local BindableEvent = game.ServerStorage:WaitForChild("BindableEvent")

local Damage = 10

script.Parent.Touched:Connect(function(hit)
	if hit then 
		if hit.Name == "Right Arm" then  
			BindableEvent:Fire(Damage)
		end
	end
end)

Listener/Receiver:

local BindableEvent = game.ServerStorage:WaitForChild("BindableEvent")

BindableEvent.Event:Connect(function(damage)
	print("received " .. damage .. " damage")
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.