Help with forwarding a client event to another client event

I am working on a fps and I need help with forwarding a client event to another client event like this:

localscript → bindableevent → localscript → remoteevent → serverscript

Im trying to create a grenade script via a massive framework localscript which fires an event to the local sided grenade in your hand which plays the fuse sound when you hold click and then when you let go it sends the event to the local grenade in your hand which deletes itself and then fires an event to the serverscript to create a new server grenade to throw in the direction of the mouse

everything should work but for some reason the local grenade doesnt pick up the event being fired

if you have any idea why this is happening please let me know thank you :slight_smile:

3 Likes

If you are going LocalScript to LocalScript on the same client/player as you seem to be doing, you need a BindableEvent instead of a RemoteEvent.
If you are going LocalScript to LocalScript between clients/players, you need to use LocalScript -> RemoteEvent -> Script -> RemoteEvent -> LocalScript

that what ive been doing ill edit it so you can see the type of events i used

Can you show me the two LocalScripts, and any output you have?

starting localscript section

mouse.Button1Down:Connect(function()
	if weapons[holding] ~= nil then
		if holding == "explosive" then
			weapons[holding].Use:Fire()
		end
	end
end)
mouse.Button1Up:Connect(function()
	if weapons[holding] ~= nil then
		if holding == "explosive" then
			weapons[holding].Throw:Fire()
		end
	end
end)

local grenade

script.Parent.Use.Event:Connect(function()

script.Parent.Handle.Fuse:Play()

end)

script.Parent.Throw.Event:Connect(function()

local mouse = game.Players.LocalPlayer:GetMouse()

game.ReplicatedStorage.Events.ThrowGrenade:FireServer(script.Parent.PrimaryPart.CFrame, mouse.Hit)

script.Parent:Destroy()

end)

server grenade throw section

game.ReplicatedStorage.Events.ThrowGrenade.OnServerEvent:Connect(function(player, position, cframe)

local grenade = game.ServerStorage.Misc.ThrownGrenade:Clone()

grenade:SetPrimaryPartCFrame(position)

local velocity = Instance.new("BodyVelocity", grenade.PrimaryPart)

grenade = game.Workspace

velocity.Velocity = CFrame.new(grenade.PrimaryPart.Position, cframe.Position + Vector3.new(0,20,0)).LookVector * 100

wait(0.1)

velocity:Destroy()

end)

it fires the event on the starting code but the grenade doesnt say anything

Correct me if I’m wrong, but bindable events only work in places where scripts run, such as workspace.

It might be the issue

i dont think so because ive used them inside of guns for things like getting the mouse pos

Legend {Origin = origin script, Reciever = receiver script}
Use Bindable Functions
BindableFunctions are:
Origin to Reciever to Origin
That saves most of the work, now just fire the remote on the origin to the server script

this isn’t going back and fourth its going to one script to another
I will use this for later things though thank you

1 Like

ok so I know the issue, the issue is that i completely forgot that local scripts only run if under a player, a character and a backpack. Thanks to the people who tried to help! :slight_smile:

1 Like

Dude what i don’t understand is why you don’t use 1 local script to handle local stuff, and 1 remote event to handle damage and stuff like that on a server script.
Forwarding data from one localscript to another in this context is useless. It is cleaner and better to just play the pin sound and throw animation in one tool.activated event, then fire the remote to handle explosions and damage on the server.

Correcting you if you’re wrong.
Bindable events run anywhere

1 Like