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

My pet script works, but conflicts with players?

Asked by 6 years ago

https://gyazo.com/928ef93d91a46743e4bab023ad2d387b

what happens ^

my script:

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(3,2+fl,3)
            pet.BodyPosition.Position = Vector3.new(cf.x,cf.y,cf.z)
            pet.BodyGyro.CFrame = torso.CFrame * CFrame.new(1,0,-3)
        else
            break
        end
    end
end

local weld = Instance.new("Weld", script.Parent)

weld.Part0=script.Parent
weld.Part1=torso
weld.C0 = script.Parent.CFrame:Inverse()
weld.C1 = torso.CFrame:Inverse()

https://gyazo.com/179a0b70be594b97d8c0dd51e1393eb4

^ the hierarchy of my Pet part

i believe it has something to do with coming close to another Torso or humanoid, how can i make it souly attached to a player and not conflict with other players?

0
Pet.CanCollide = false will make it not conflict with other players Vmena 87 — 6y
0
collision is already off, doesnt fix it even if i was to script it in. InsaneL0L 10 — 6y
0
pet is a child of character right? I would try it in workspace instead if it is Vulkarin 581 — 6y
0
yeah it is, what do you recomend to point the pet to the specific player then? i need Filering Enabled keep in mind, and others to see pets InsaneL0L 10 — 6y
View all comments (5 more)
0
parent isn't going to matter for FE, fyi filter enabled is no longer a toggle instead it is always on Vulkarin 581 — 6y
0
parenting stuff to character can cause some strange side effects so I would recommend parenting it to something else in workspace or just workspace itself Vulkarin 581 — 6y
0
when i parent it to the workspace or whatever i endup parenting to, how to i make it follow a specific player then if its not simply its parent? InsaneL0L 10 — 6y
0
by that i mean, in my script inside the pet, what would i put instead of parent referencing the players character? i tried using localplayer.Character and it wouldnt follow InsaneL0L 10 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Got it to work, so what i had it originally do was in a PlayerAdded function, clone the pet into the player character and let the local script inside the pet do the work for how it follows the player, but what i changed was, inside the Player Added script, i added what was originally in the local pet script into the function and it worked perfect. so it must have been a conflict with two players having a local script. So now its all the server running the pets.

0
Thank you for posting your solution. Paintertable 171 — 6y
Ad

Answer this question