Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ------------
- INSTRUCTION:
- ------------
- 1.Create Script and put to ServerScriptService
- 2.Copy all code below to script..
- 3.Create Model change name to Pet and put to ReplicatedStorage
- 4.Create inside Model(Pet) Part and (change name Pet)
- 5.Go to Model(Pet)->Part(Pet) and inside of Part create BodyGyro and BodyPosition don't change name
- 6.in BodyPosition change (D = 1250) and (MaxForce = 8000,8000,8000) and (P = 6000)
- 7.Run!
- ------------
- if you did well what I described above, you will have no problems...
- if you have problems/bugs/errors pm me in game!
- My Profile:
- https://www.roblox.com/users/140427102/profile
- Tutorial how to script configure:
- https://www.youtube.com/watch?v=8FIQGebSk9M
- ------------
- Enjoy guys! this Fixed version of pet following don't edit it if you don't know what you are doing
- --]]
- local part = nil -- handle to our animal
- local BodyPosition = nil -- animal position in the world 3D
- local BodyGyro = nil -- speed of the animal's turnover
- local StoreSearched = {} -- store variable bool of players (if we eqiupped pet don't create anymore pets on account) this variable holds false/true of players
- local storeCharacters = {} -- store characters of players
- local storeHeads = {} -- storage humanoid heads of players
- local StoreSearched2 = {} -- it does the same as above
- local players = game:GetService("Players")
- local pets = game.ReplicatedStorage:FindFirstChild("Pet")
- local petsinv = nil -- Store Clone pet
- game.Players.PlayerAdded:Connect(function(plr)
- plr.CharacterAdded:Connect(function()
- StoreSearched2[plr.Name] = false
- end)
- end)
- game.Players.PlayerRemoving:Connect(function(plr)
- StoreSearched[plr.Name] = nil
- storeCharacters[plr.Name] = nil
- storeHeads[plr.Name] = nil
- StoreSearched2[plr.Name] = nil
- end)
- while wait(0.010) do
- for i,v in pairs(players:GetPlayers()) do
- if v then
- if storeCharacters[v.Name] then
- if storeCharacters[v.Name] ~= nil and storeCharacters[v.Name]:FindFirstChild("Humanoid") and storeCharacters[v.Name].Humanoid.Health > 0 and StoreSearched2[v.Name] == false then
- for i,s in pairs(storeCharacters[v.Name]:GetChildren()) do
- if s:IsA("Model") and s.Name == "Pet" then
- StoreSearched[v.Name] = true
- break
- else
- StoreSearched[v.Name] = false
- end
- end
- if StoreSearched[v.Name] == false then
- print("this player don't have pet")
- if pets and storeCharacters[v.Name].Humanoid.Health > 0 then
- local petsinv = pets:Clone()
- petsinv.Parent = storeCharacters[v.Name]
- petsinv:PivotTo(storeHeads[v.Name].CFrame)
- end
- end
- end
- if storeCharacters[v.Name].Humanoid.Health <= 0 and storeCharacters[v.Name]:FindFirstChild("Pet") then
- StoreSearched2[v.Name] = true
- storeCharacters[v.Name].Pet:Destroy()
- end
- end
- end
- end
- for i,v in pairs(players:GetPlayers()) do
- if v then
- storeCharacters[v.Name] = v.Character
- if not storeCharacters[v.Name] then
- storeCharacters[v.Name] = v.CharacterAdded:Wait()
- end
- if storeCharacters[v.Name] then
- storeHeads[v.Name] = storeCharacters[v.Name]:FindFirstChild("UpperTorso")
- if storeHeads[v.Name] ~= nil then
- part = (storeCharacters[v.Name]:FindFirstChild("Pet") and storeCharacters[v.Name].Pet:FindFirstChild("Pet"))
- if part ~= nil then
- BodyGyro = part.BodyGyro
- BodyPosition = part.BodyPosition
- if v and BodyGyro ~= nil and BodyPosition ~= nil then
- part.CFrame = CFrame.new(part.Position,storeHeads[v.Name].Position) * CFrame.Angles(0,math.rad(0),0)
- BodyGyro.CFrame = CFrame.new(part.Position,storeHeads[v.Name].Position) * CFrame.fromEulerAnglesXYZ(0,math.rad(45),0)
- if storeHeads[v.Name].Size.Magnitude <= 77 then
- BodyPosition.Position = storeHeads[v.Name].Position + (storeHeads[v.Name].Size /2) + Vector3.new(3.3,3.3,3.3)
- else
- BodyPosition.Position = storeHeads[v.Name].Position + (storeHeads[v.Name].Size /1.7)
- end
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement