I am working on an air hockey table, and I am using things like "BodyVelocity" to move the Handles. I am using remote events for this, but they don't seem to be firing at all. What's going on? Here is the script:

Client:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local UserInputService = game:GetService("UserInputService")
local KeyDown = game.ReplicatedStorage.KeyDown
local KeyUp = game.ReplicatedStorage.KeyUp

humanoid.Seated:Connect(function(Sitting, seat)
	if Sitting then
		if seat.Parent.Name == "P1Seat" then
			UserInputService.InputBegan:Connect(function(Input)
				if Input.KeyCode == Enum.KeyCode.D then
					local rightDown = UserInputService:IsKeyDown(Enum.KeyCode.D)
					if rightDown then
						KeyDown:FireServer(Enum.KeyCode.D)
					end
				elseif Input.KeyCode == Enum.KeyCode.A then
					local leftDown = UserInputService:IsKeyDown(Enum.KeyCode.A)
					if leftDown then
						KeyDown:FireServer(Enum.KeyCode.A)
					end
				end
			end)
			
			UserInputService.InputEnded:Connect(function()
				KeyUp:FireServer()
			end)
		end
	else
		KeyUp:FireServer()
	end
end)

Server:

local KeyDown = game.ReplicatedStorage.KeyDown
local KeyUp = game.ReplicatedStorage.KeyUp
local playerOne = workspace.AirHockeyHandle1.BodyVelocity

KeyDown.OnServerEvent:Connect(function(player, key)
	print("Event Received")
	if key == Enum.KeyCode.D then
		playerOne.Velocity = Vector3.new(-1, 0, 0)
	end
	
	if key == Enum.KeyCode.A then
		playerOne.Velocity = Vector3.new(1, 0, 0)
	end
end)

KeyUp.OnServerEvent:Connect(function(player)
	playerOne.BodyForce = Vector3.new(0, 0, 0)
end)

4 comments

0

this looks like a cosutom movement, read this

0

No, im moving a part, not a player

0

Indent your code.