I’m trying to make it so players can spawn a boat but whenever I the boat is cloned the hinges break so the propellers fall off making the boat immobile. I tried using :MakeJoints() but that didn’t work. You’ll find the relevant code in the “–//Clone Boat\–” section.
local events = game.ReplicatedStorage.RemoteEvents
local spawns = game.Workspace.Everything.BlimpSpawns
local boatSpawns = game.Workspace.Everything.BoatSpawns
local randomObject = Random.new()
local function pickRandomSpawnPosition(possibleSpawnPositions)
-- Pick a pseudorandom number within the range of 1 - however many children your possibleSpawnPositions folder has
local randomInt = randomObject:NextInteger(1, #possibleSpawnPositions)
-- Return the child in the "randomInt"-th index's CFrame. (i.e. if "randomInt" is five, will return the fifth entry in possibleSpawnPositions
return possibleSpawnPositions[randomInt].CFrame
end
--//Drop Blimp\\--
local function teleportBlimpToSpawnPosition(blimp, possibleSpawnPositions)
-- Select a random spawn pos
local spawnPosition = pickRandomSpawnPosition(possibleSpawnPositions)
-- Note: This is assuming "blimp" is a model that has a primarypart.
-- Set's the blimp's cframe to that of our randomly selected spawn position + an offset of the blimp's height divided by two
-- We offset it so that it doesn't spawn inside of the BlimpPos part.
blimp:SetPrimaryPartCFrame( CFrame.new(spawnPosition.X, spawnPosition.Y + blimp:GetExtentsSize().Y/2, spawnPosition.Z) )
-- Set the blimp's parent
blimp.Parent = workspace
end
--//Drop Boat\\--
local function teleportBoatToSpawnPosition(boat, possibleSpawnPositions)
-- Select a random spawn pos
local spawnPosition = pickRandomSpawnPosition(possibleSpawnPositions)
-- Note: This is assuming "blimp" is a model that has a primarypart.
-- Set's the blimp's cframe to that of our randomly selected spawn position + an offset of the blimp's height divided by two
-- We offset it so that it doesn't spawn inside of the BlimpPos part.
boat:SetPrimaryPartCFrame( CFrame.new(spawnPosition.X, spawnPosition.Y + boat:GetExtentsSize().Y/2, spawnPosition.Z) )
-- Set the blimp's parent
boat.Parent = workspace
end
--//Clone Boat\\--
events.CloneBoat.OnServerEvent:connect(function(player, boat)
local clone = boat:Clone()
clone.Wheel1:MakeJoints()
clone.Wheel2:MakeJoints()
local team = player.TeamColor == BrickColor.new("Bright red") and "Red" or "Blue"
teleportBoatToSpawnPosition(clone, boatSpawns[team]:GetChildren())
clone.Name = player.Name.." Boat"
local playername = Instance.new("StringValue", clone)
playername.Name = "PlayerName"
playername.Value = player.Name
game.Workspace:WaitForChild(player.Name.. " Boat")
if game.Workspace:FindFirstChild(player.Name.." Boat") then
player.Character.HumanoidRootPart.CFrame = clone.VehicleSeat.CFrame
end
--//Clone Blimp\\--
events.CloneBlimp.OnServerEvent:connect(function(player, blimp)
local clone = blimp:Clone()
local team = player.TeamColor == BrickColor.new("Bright red") and "Red" or "Blue"
teleportBlimpToSpawnPosition(clone, spawns[team]:GetChildren())
clone.Name = player.Name.." Blimp"
local playername = Instance.new("StringValue", clone)
playername.Name = "PlayerName"
playername.Value = player.Name
game.Workspace:WaitForChild(player.Name.. " Blimp")
if game.Workspace:FindFirstChild(player.Name.." Blimp") then
player.Character.HumanoidRootPart.CFrame = clone.Blimp.person299.CFrame
end
--//Character Added\\--
player.CharacterAdded:connect(function()
if game.Workspace:FindFirstChild(player.Name.." Blimp") or game.Workspace:FindFirstChild(player.Name.." Boat") then
local oldblimp = game.Workspace:FindFirstChild(player.Name.." Blimp")
local oldBoat = game.Workspace:FindFirstChild(player.Name.." Boat")
oldblimp:remove()
oldBoat:remove()
print("blimp removed")
end
end)
end)
end)
--//Player Leaves\\--
game.Players.PlayerRemoving:connect(function(plr)
if game.Workspace:FindFirstChild(plr.Name.." Blimp") then
game.Workspace:FindFirstChild(plr.Name.." Blimp"):remove()
elseif game.Workspace:FindFirstChild(plr.Name.." Boat") then
game.Workspace:FindFirstChild(plr.Name.." Boat"):remove()
end
end)