I'm working on a game and I've run into a problem scripting the motion of the forks of a forklift. I've got the model done, but no matter what I try in my script using CFrame and other API calls, I cannot change the position of the forks relative to the beam that holds them. If I break the joint between the forks and the beam, then I can move them, but then of course they don't work as a fork lift.
Here is the script I've tried most recently: -- ************************************************************************************ -- LiftTruckOperControlEven.OnServerEvent handler
-- In this function we will process the received events from the EventServer, fired by -- key press events handled by the Local Script. This function must -- * parse the sending player -- * parse the event "type" sent in arg1 -- * Confirm the player has a vehicle created of the correct type -- * Confirm the player is the occupant of the vehicle with their name on it
game.Workspace.LiftTruckOperControlEvent.OnServerEvent:connect(function(player, arg1) -- define the function that will be called when the event is fired
if (player ~= nil) then
local vehicleName = player.Name.."ContainerLiftTruck"
if ( game.Workspace:FindFirstChild(vehicleName) and
(player.VehicleTag.Value == "ContainerLiftTruck") ) then
local playersTruck = game.Workspace:FindFirstChild(vehicleName)
local truckNetworkOwner = playersTruck.VehicleSeat:GetNetworkOwner()
-- lets make sure the networkowner is the one in the seat
if (truckNetworkOwner.Name == player.Name) then
-- network owner is in the driver's seat
if (arg1 == "up") then
print (vehicleName.." Going Up!")
local startingCFrame = playersTruck.GrabberAssembly:GetPrimaryPartCFrame()
local newCFrame = startingCFrame + Vector3.new(0, 5, 0)
print("Start: ",startingCFrame)
print("New: ", newCFrame)
--playersTruck.ContainerGrabAssembly:SetPrimaryPartCFrame(newCFrame)
--playersTruck.ContainerGrabAssembly.LiftTraveller.CFrame = newCFrame
--playersTruck.ContainerGrabAssembly:TranslateBy(Vector3.new(0, 5, 0))
print(playersTruck.GrabberAssembly:GetPrimaryPartCFrame())
elseif (arg1 == "down") then
print (vehicleName.." Going Down!")
else
print (vehicleName.." Arg1 not what I expected")
end
else -- someone other than the owner is in the seat
end
end
else
print ("No Vehicle Found by that name")
end
end)
In order for the new CFRAME to take effect, do I need to break the joint between the grabber assembly and the beam, then remake it after its done moving?
If anyone can help me with this scripting issue I would really appreciate it. Thanks!
- EngineerTim

2 comments
Sorry about the layout. It looked much cleaner in NotePad++
Sorry I can't be bothered helping anyone now I almost had a heart attack and I had to carry a new lounge set into my house.