Hi, so I have a motorcycle but I want it that when it hits the ground to break and respawn to a specific location on the map. Does anyone have any idea how to do that if so please reply to this post, thanks!
You have to make your own logic to determine if the motorcycle breaks or
not, and if it does, you clone it from somewhere else and CFrame it to a specified CFrame and boom.
I think you can store a last car velocity magnitude. Everytime, when you minus a last velocity with currently velocity and the left value is more than amount. Means that the object sunddenly lose it velocity which mean it has to hit some objects
But how do I break it though when it hits the other part?
using model:RemoveJoints() might be the solution for it!
Well, the hard thing is that if you use .Touched
event, any singe parts your motorcycle touches will trigger it, I suggest you to check the motorcycle’s velocity magnitude to see if the motorcycle hit something in a fast speed.
No it’s fine for me if any small part of the motorcycle touches.
No like, even though they are connecting or touching each other, it will still trigger the event. So you should blacklist parts that you don’t want the motorcycle to trigger the .Touched
event.
I just want to Destroy the motorcycle as soon as they touch.
What I would do:
local model --TODO: set to model
model.Parent = nil
local respawn
respawn = function()
local newModel = model:Clone()
newModel.PrimaryPart.Touched:Connect(function(hit) -- Select the hitbox part, in this case I used the Model.PrimaryPart
-- TODO: check if hit is valid, if not return/end-function
newModel:Destroy()
respawn()
end)
newModel.Parent = Workspace
end
respawn()
local baseplate = workspace:WaitForChild("Baseplate") -- change this to the name of the floor part
task.spawn(function()
while task.wait() do
local touchingFloorParts = baseplate:GetTouchingParts()
for _, part in ipairs(touchingFloorParts) do
if part:FindFirstAncestor("Bike") then --change to name of bike model
local bike = part:FindFirstAncestor("Bike")
bike:PivotTo(CFrame.new(0, 0, 0)) --this will pivot the bike to a cframe value of 0, 0, 0 in the worldspace
end
end
end
end)
This will basically check if any of the bike’s parts are touching a baseplate (can be changed to a floor) and will then move the bike model to some other location.