[HELP] Bindable Event question

Basically I am trying to figure out the code to put in the event listener

This one is the code that I made with some help to detect the player touch

local debounce = false
local GroupID = 5033016
local GEV = game.Workspace.DetectorEvent

Alfa.Touched:Connect(function(hit)
	if debounce then return end
	
	
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		debounce = true
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		print(player.Name)
		
	   if player:IsInGroup(GroupID) then
		print(player.Name.. " Is In Group")
		GEV:Fire()
	
	end
				
		
	end
	wait(2)
	debounce = false
end)```

Now this one is the event listener that I want to figure out if I need to do the whole script again to work or if I do something different.

```local EV = game.Workspace:WaitForChild("BindableEvent")


EV.Event:Connect(function()
	
	--I know that the script goes here but I need to do the whole script again?
	
	
end)```
1 Like

Well… what exactly do you want to go inside that event?

It’s kind of hard to answer such a broad question.

Do you want it to do something specific to the player? Or something server-wide?

For example, you would do something like this if you want to give the player 5 gold if they touch the part:

...whatever your code is before
if player:IsInGroup(whatever) then
    GEV:Fire(player)
end

Then in the event listener:

GEV.Event:Connect(function(player)
    game.ServerStorage.PlayerData[player.Name].Gold.Value = game.ServerStorage.PlayerData[player.Name].Gold.Value + 5
end)
3 Likes

That’s everything that I needed, if something happens in call you again.

2 Likes

Oh, I think you mean the variables, if you have to write them again. When using :Fire(), you can set in values inside the brackets as it accepts a tuple.

The .Event listener’s function arguments will include the tuple in respective order from :Fire(). Therefore if you want to pass some variables into the event, do it.

Reviewing the code here, I can see that the if statements already filtered the outputs. Only players that is in group will fire the event and do not require a second if statement.

2 Likes