BindableEvent events don't get detected

Hello everyone, I’m working on a basic car and I have a script which copies and enables a localScript to player character after player sitting in the seat. That localScript’s job is firing a bindable event when player uses WASD keys while sitting in that seat.

Issue is, CarMove script doesn’t detect bindable event fires.

LocalScript copier:

local seat = script.Parent
local actions = seat.Actions.ActionBind

seat.ChildAdded:Connect(function(child)
	if child.Name == "SeatWeld" and child:IsA("Weld") and child.Part1.Name == "HumanoidRootPart" then
		local plr = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		if plr then
			seat:SetNetworkOwner(plr)
			local scriptClone = actions:Clone()
			scriptClone.Parent = plr.Character
			scriptClone.Name = "CarControls"
			scriptClone.Disabled = false
		end
	end
end)

seat.ChildRemoved:Connect(function(child)
	if child.Name == "SeatWeld" and child:IsA("Weld") and child.Part1.Name == "HumanoidRootPart" then
		seat:SetNetworkOwnershipAuto()	
		local plr = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		if plr then
			local controls = plr.Character:FindFirstChild("CarControls")
			if controls then
				controls:Destroy()
			end
		end
	end
end)

LocalScript for checking input:

local plr = game.Players.LocalPlayer
local shortcuts = require(script:WaitForChild("Shortcuts"))
local uis = game:GetService("UserInputService")
local event = script.CarMove


uis.InputBegan:Connect(function(input, GPE)
	if GPE == false then
		if input.UserInputType == Enum.UserInputType.Keyboard then
			if input.KeyCode == shortcuts.W then
				event:Fire("W 0")
			elseif input.KeyCode == shortcuts.A then
				event:Fire("A 0")
			elseif input.KeyCode == shortcuts.S then
				event:Fire("S 0")
			elseif input.KeyCode == shortcuts.D then
				event:Fire("D 0")
			end
		end
	end
end)

uis.InputEnded:Connect(function(input, GPE)
	if GPE == false then
		if input.UserInputType == Enum.UserInputType.Keyboard then
			if input.KeyCode == shortcuts.W then
				event:Fire("W 1")
			elseif input.KeyCode == shortcuts.A then
				event:Fire("A 1")
			elseif input.KeyCode == shortcuts.S then
				event:Fire("S 1")
			elseif input.KeyCode == shortcuts.D then
				event:Fire("D 1")
			end
		end
	end
end)

CarMove script:

local seat = script.Parent
local BackHinge = script.Parent.Parent.Parent.BackPart.BackNeck.BackHinge
local motorFR = script.Parent.Parent.Parent.Front.WheelFR.HingeConstraint
local motorFL = script.Parent.Parent.Parent.Front.WheelFL.HingeConstraint
local CheckInput = require(script.Parent.CheckInput)

local function listenInput(player)
	local ControlScript = player.Character:WaitForChild("CarControls")
	local Event
	if ControlScript then
		Event = ControlScript:WaitForChild("CarMove")
	end
	if Event then
		Event.Event:Connect(function(data)
			if type(data) == 'string' then --this never runs
				CheckInput.CheckInput(data, BackHinge, motorFR, motorFL)
			else
				assert("Data can only be string value", false)
			end
		end)
	end
end

seat.ChildAdded:Connect(function(child)
	if child.Name == "SeatWeld" and child:IsA("Weld") and child.Part1.Name == "HumanoidRootPart" then
		local plr = game.Players:GetPlayerFromCharacter(child.Part1.Parent)
		if plr then
			listenInput(plr)
		end
	end
end)
1 Like

You should be using a RemoteEvent, not a BindableEvent, for client/server communication.