How to have 1 module that can handle both client and server + allow communcation

When a player uses their streak item, I want to be able to have 1 module that can handle anything for the client and server (so I dont need to 2 seperate modules) but I can’t have communication, as the Bindable is obviously being created each times its required, and I imagine there’s a bindable for the client and server, instead of just 1 where they can communicate.

Does anyone have tips on this? Or if there’s a better way to handle my streaks in an efficient and secure way

local Bindable = Instance.new("BindableEvent")

--// Use the grenade streak
function Grenade.Use()
	
	if RunService:IsServer() then
		print("SERVER")
		local NewMaid = Maid.new()
		
		local function CharacterHit(hitPlayer, hitCharacter)
			print(0)
			if not hitPlayer or not hitCharacter then return end
			print(1)
			if hitPlayer.Character ~= hitCharacter then return end
			print(2)
			NewMaid:DoCleaning()
		end
		
		Bindable.Event:Connect(CharacterHit) -- NewMaid:GiveTask(
	else -- Client stuff
		local GrenadeItem = GrenadeItem:Clone()
		GrenadeItem.BrickColor = Player.TeamColor
		
		GrenadeItem.Parent = workspace
		
		GrenadeItem.CFrame = Camera.CFrame
		GrenadeItem:ApplyImpulse(GrenadeItem.CFrame.LookVector * SPEED)
		
		delay(EXPLODE_TIME, function()
			GrenadeItem.Anchored = true
			
			local Explode = GrenadeItem:Clone()
			Explode.CanCollide = false
			
			Explode.Parent = workspace
			
			local ExplodeTween = TweenService:Create(
				Explode,
				TweenInfo.new(1),
				{
					Size = Vector3.new(RADIUS, RADIUS, RADIUS),
					Transparency = 1
				}
			)
			ExplodeTween:Play()
			
			local Teams = GameSettings:GetAttribute("Teams")
			
			-- Check radius of players
			for _, player in pairs(Players:GetPlayers()) do
				if player == Player then continue end -- Don't affect ourselves
				
				if player.Team == Player.Team and Teams then continue end -- Don't affect team mates
				
				local Character = player.Character
				if not Character then continue end
				
				if (player.Character.HumanoidRootPart.Position - GrenadeItem.Position).Magnitude <= RADIUS then
					local Creator = Instance.new("ObjectValue")
					Creator.Name = "Creator"
					Creator.Value = Player.Character
					Creator.Parent = Character.Humanoid
					
					Debris:AddItem(Creator, 2)
					
					Bindable:Fire(player, Character)
					
					Character.Humanoid.Health = 0
				end
			end
			print("EXPLODE")
			Bindable:Fire(1, 1)
			GrenadeItem:Destroy()
		end)
	end
end

I guess you can do just like what I did: 2 functions (one for client, one for server). But as I see that you can use RunService and check if the function is called on client or server, that would be easier. I suggest checking with RunService:IsClient() too for the client function.

Adding the IsClient() doesn’t fix my problem though :confused:

Then how about make 2 functions? That worked on my module.

Question is referring to being able to communicate between those functions tho

Nvm, realised I wasa using Bindable event and not a RemoteEvent :man_facepalming: