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

: SetPrimaryPartCFrame () having issues, can it be fixed?

Asked by 2 years ago

Hi, I'm doing a "farm" game where you have to sow and harvest. When sowing, the plant is cloned out of "game.Lighting" and then teleported to the part with: SetPrimaryPartCFrame (), but as soon as I drive over an already sown spot in the field, the game seems to lag. I believe this is because there are many parts in the plant (model) and these are teleported (30 parts). I hope this can be fixed. Here the script:

script.Parent.Touched:Connect(function(part)
    if part.Name == "SeedPlant" then
        local plr = game.Players[script.Parent.Parent.Parent.Parent.Owner.Value]
        if part.PlantedSeed.Value == "LEER" and part.Parent.Parent.Owner.Value == script.Parent.Parent.Parent.Parent.Owner.Value and plr.Plants[plr.Seeding.Value].Value >= 0 and plr.Plants[plr.Seeding.Value].Value ~= 0 then
        part.PlantedSeed.Value = plr.Seeding.Value
        plr.Plants[plr.Seeding.Value].Value = plr.Plants[plr.Seeding.Value].Value  -1
        local plant = game.Lighting[plr.Seeding.Value]:Clone()
        plant.Parent = part 
        plant:SetPrimaryPartCFrame(part.CFrame)
        end

    end
end)

...and here a youtube video: https://youtu.be/VFwBZ3irRbU

I look forward to answers : )

Answer this question