Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i make it so it gives a pet to everyone who joins?

Asked by
oilkas 364 Moderation Voter
7 years ago
Edited 7 years ago
local service = game:GetService("TweenService")
local ti = TweenInfo.new(
    0.05,
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.In,
    0,
    false,
    0
)
game.Players.PlayerAdded:connect(function(plr)
wait(2)
local part = game.ReplicatedStorage.Cat:Clone()
part.Parent = workspace[plr.Name].Torso
part.CanCollide = false
part.Anchored = true
while true do
    wait(0.05)
    local position = {CFrame = CFrame.new(plr.Character['Head'].Position + Vector3.new(2,1,0))}
    local movepet = service:Create(part,ti,position)
    movepet:Play()
    part.Rotation = game.Workspace[plr.Name].Torso.Rotation
end
end)

Here is my script. This is a pet script which follows you. how can i fix this?. its a Script. If I would make it as a LocalScript in a player, Only you would see it. Please tell a way to fix this.

0
fix indentation plz Programical 653 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Alright,

  1. Add a mesh to "ReplicatedStorage", and make the mesh ID what ever you would like.

  2. Name the mesh, "Pet".

  3. Insert a LocalScript into "StarterGui".

  4. Inside of the script, add this piece of code:

local plr = game.Players.LocalPlayer
wait(2)
local part = Instance.new("Part", workspace[plr.Name].Torso)
part.CanCollide = false
part.Anchored = true
part.Size = Vector3.new(1, 1, 1)
local mesh = game.ReplicatedStorage.Pet
mesh:Clone().Parent = part
local direction = CFrame.new(part.Position, plr.Character['Left Leg'].Position).lookVector
local increment = direction * 4
while true do
    wait()
    part.CFrame = game.Workspace[plr.Name]['Torso'].CFrame + (direction * increment) + Vector3.new(-5, 0, 0)
    part.Rotation = game.Workspace[plr.Name]['Torso'].Rotation + (direction * increment) + Vector3.new(-1, -2, increment)
end
0
Also btw, When I test out the script. The pet is to close to the arm, I wanted it to hover over it but Maybe you can figure it out LennonLight 95 — 7y
Ad

Answer this question