I'm trying to make the body velocity increase when your in a seat, but it can't find the seat.
Local Script inside StarterPlayerScripts
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local SpeedValue = player.ValueFolder.SpeedValue
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(KeyPressed)
if KeyPressed == "w" then
if character.Humanoid.Sit == true then
local SeatName = character.Humanoid.SeatPart.Name
print(SeatName)
SpeedValue.Value = SpeedValue.Value + 1
print(SpeedValue.Value)
game.ReplicatedStorage.W:FireServer(character, SpeedValue, SeatName)
end
end
if KeyPressed == "s" then
if character.Humanoid.Sit == true then
local SeatName = character.Humanoid.SeatPart.Name
print(SeatName)
SpeedValue.Value = SpeedValue.Value - 1
print(SpeedValue.Value)
game.ReplicatedStorage.W:FireServer(character, SpeedValue, SeatName)
end
end
end)
Server Script in ServerScriptStorage
game.ReplicatedStorage.W.OnServerEvent:Connect(function(character, SpeedValue, SeatName)
local seat = game.Workspace:FindFirstChild(SeatName)
local look = seat.Parent.Floor.CFrame.LookVector
seat.Parent.Floor.BodyVelocity.Velocity = look * SpeedValue.Value
end)
game.ReplicatedStorage.S.OnServerEvent:Connect(function(character, SpeedValue, SeatName)
print("S")
end)
The error line:
Class37Seat -- Print
6 -- Print
19:46:44.603 - Argument 1 missing or nil -- Error
19:46:44.604 - Stack Begin
19:46:44.604 - Script 'ServerScriptService.Script', Line 2
19:46:44.604 - Stack End
Thank you for any help!
