Moving Object, Filtering Enabled help?
So I'm trying to make a boat seat move and I'm not 100% clear on Filtering Enabled yet but if you can help and explain this to me a bit, I would really appreciate it.
I don't know if I did this right?
so Both the MoveEvent and StopEvent are in the VehicleSeat, as well as the localscript and script, are in the vehicleseat as well.
03 | local Players = game:GetService( "Players" ) |
04 | local UserInputService = game:GetService( "UserInputService" ) |
05 | local MoveEvent = script:WaitForChild( "MoveEvent" ) |
06 | local StopEvent = script:WaitForChild( "StopEvent" ) |
10 | UserInputService.InputBegan:connect( function (Input) |
11 | local KeyCodeName = Input.KeyCode.Name |
13 | if KeyCodeName = = "W" then |
14 | MoveEvent:FireServer( "Forwards" ) |
15 | elseif KeyCodeName = = "S" then |
16 | MoveEvent:FireServer( "Backwards" ) |
17 | elseif KeyCodeName = = "A" then |
18 | MoveEvent:FireServer( "Left" ) |
19 | elseif KeyCodeName = = "D" then |
20 | MoveEvent:FireServer( "Right" ) |
23 | if KeyCodeName ~ = "Unknown" then |
24 | KeysDown [ KeyCodeName ] = true |
28 | UserInputService.InputEnded:connect( function (Input) |
29 | local KeyCodeName = Input.KeyCode.Name |
31 | if KeyCodeName = = "W" then |
33 | MoveEvent:FireServer( "Backwards" ) |
35 | StopEvent:FireServer( "Forwards" ) |
37 | elseif KeyCodeName = = "S" then |
39 | MoveEvent:FireServer( "Forwards" ) |
41 | StopEvent:FireServer( "Backwards" ) |
43 | elseif KeyCodeName = = "A" then |
45 | MoveEvent:FireServer( "Right" ) |
47 | StopEvent:FireServer( "Left" ) |
49 | elseif KeyCodeName = = "D" then |
51 | MoveEvent:FireServer( "Left" ) |
53 | StopEvent:FireServer( "Right" ) |
57 | if KeyCodeName ~ = "Unknown" then |
58 | KeysDown [ KeyCodeName ] = nil |
03 | local Boat = script.Parent |
04 | local Players = game:GetService( "Players" ) |
06 | local MoveEvent = script:WaitForChild( "MoveEvent" ) |
07 | local StopEvent = script:WaitForChild( "StopEvent" ) |
10 | maxspeed = Boat.MaxSpeed |
11 | Boat.BodyPosition.position = Boat.Position |
12 | Boat.BodyGyro.cframe = Boat.CFrame |
15 | Boat.ChildAdded:connect( function (Weld) |
16 | if Weld:IsA( "Weld" ) then |
17 | local Torso = Weld.Part 1 |
23 | Boat.ChildRemoved:connect( function (Child) |
26 | MoveEvent.OnServerEvent:connect( function (Player, Type) |
27 | if Type = = "Forwards" then |
29 | if speed < maxspeed then speed = speed + 0.1 end |
30 | Boat.BodyVelocity.velocity = Boat.CFrame.lookVector*speed |
31 | elseif Type = = "Backwards" then |
33 | if speed < 18 then speed = speed + 0.1 end |
34 | Boat.BodyVelocity.velocity = Boat.CFrame.lookVector*-speed |
35 | elseif Type = = "Left" then |
37 | Boat.BodyGyro.cframe = Boat.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ( 0 , 0.01 , 0 ) |
38 | elseif Type = = "Right" then |
40 | Boat.BodyGyro.cframe = Boat.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ( 0 ,- 0.01 , 0 ) |
44 | StopEvent.OnServerEvent:connect( function (Player, Type) |
45 | if Type = = "Forwards" or Type = = "Backwards" then |
47 | elseif Type = = "Left" or Type = = "Right" then |