![]() RenderPets(workspace:FindFirstChild(player.Name."-Pets"), player, deltaTime) Main function to smoothly move the pets into position ![]() If not workspace:FindFirstChild(player.Name."-Pets") then continue end if the player does not have a pet folder then we can skip them loops through players to get their pets folderįor i, player in pairs(game.Players:GetPlayers()) do RunService.Heartbeat:Connect(function(deltaTime) V:SetPrimaryPartCFrame(v.PrimaryPart.CFrame:Lerp(c, smoothness*deltaTime)) We multiply smoothness by deltaTime so it's frame independent Lerping the pet to the target CFrame so its more smooth creating the CFrame where the pet should be Offset = Vector3.new(offset.X, verticalPos, offset.Z) the or is for if the ray did not hit the floor, the pet will be at character Y position Local offset = backwardsOffset + *horizontalOffsetįunction CheckForFloor(offset:Vector3, filter:) or Local backwardsOffset = playerHrp.Position - *behindPlayerDistance - *distanceBetweenRows*(math.floor(petIndex/maxPetsPerRow)) HorizontalOffset = petIndex%maxPetsPerRow * distancebetweenColumns - ((maxPetsPerRow-1)*distancebetweenColumns)/2 MaxPetsPerRow = numOfPets - maxPetsPerRow*math.floor(numOfPets/maxPetsPerRow) HorizontalOffset = (petIndex%maxPetsPerRow * distancebetweenColumns) - ((maxPetsPerRow-1)*distancebetweenColumns)/2 If petIndex - maxPetsPerRow*math.floor(numOfPets/maxPetsPerRow) < 0 then Main function to change Position formationsįunction GridPositionGen(numOfPets, petIndex, playerHrp) :Vector3 ![]() Local smoothness = 4 -how fast the pet gets into position Local floatHeight = 3 -height above the ground Local behindPlayerDistance = 3 -distance from player Local distanceBetweenRows = 3 -gap between rows Local distancebetweenColumns = 5 -gap between columns Local maxPetsPerRow = 3 -how many pets can be in one row Local RunService = game:GetService("RunService") Now using a local script inside StarterCharacter: -getting RunService Workspace:FindFirstChild(player.Name."-Pets"):Destroy() If not workspace:FindFirstChild(player.Name."-Pets") then return end Make sure sure to delete the pets when the player leaves But for the sake of the tutorial I am just going to add 9 This is where you want to get what pets the player has and put them into Local petsFolder = Instance.new("Folder", workspace) creating player pet folder named by the player name followed by "-Pets" Using a server script inside ServerScriptService we can add a folder to workspace labeled by the player followed by “-Pets” so we can put our pets in that folder -This code will fire every time a new player enters the game But as long your does not rely on the pets attacking enemies or getting coins this should be fine
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |