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

Fix pets being shown to other players?

Asked by 5 years ago

Si, im trying to make a thing where a pet follows you i got that to work but it doesn't show for other players could someone help? These are the scripts in the Gui And the Pet

local target = game.ReplicatedStorage.Dragonite

script.Parent.MouseButton1Click:connect(function()
 if game.Players.LocalPlayer.character:FindFirstChild("Pet") == nil then
    local pet = target:Clone()
    pet.Parent = game.Players.LocalPlayer.Character
    pet.LocalScript.Disabled = false
   end
end)
--Script for gui
local char = script.Parent.Parent
local hum = char:FindFirstChild("Humanoid")
local torso = char:FindFirstChild("Torso")
local pet = script.Parent

local maxFloat = 1
local floatInc = 0.025
local sw = false
local fl = 0

while true do
    wait()
    if not sw then
        fl = fl + floatInc
        if fl >= maxFloat then
            sw = true
        end
    else
        fl = fl - floatInc
        if fl <=-maxFloat then
            sw = false
        end
    end
    if pet ~= nil and hum ~= nil and torso ~= nil then
        if hum.Health >= 0 then
            local cf = torso.CFrame * CFrame.new(7,4+fl,3)
            pet.BodyPosition.Position = Vector3.new(cf.x,cf.y,cf.z)
            pet.BodyGyro.CFrame = torso.CFrame * CFrame.new(3,5,-3)
        else
            break
        end
    end
end
--Script in the pet

There local scripts to.

0
Thats because you're adding the pet locally. DinozCreates 1070 — 5y
0
What do you mean by that? Sorry im a bad scripter awesomwkidd 11 — 5y
0
You need to fire a remote event to the server so the server can create pet instead of the client. What you are doing right now is that you are creating the pet in a LocalScript, so only the LocalPlayer can see the pet. It does not replicate to the server. Rheines 661 — 5y
0
Where do i put the remote event? awesomwkidd 11 — 5y
View all comments (2 more)
0
If you Instance.new on the client (LocalScript), nobody can see it. You need to create the part, move it and such on the server. User#26471 0 — 5y
0
I tried the remote event and it didn't work. awesomwkidd 11 — 5y

Answer this question