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

script to clone spawner not working anythin done wrong, i get no errors?

Asked by
wswswff 39
1 year ago
local p = script.Parent
local db = false
p.Touched:Connect(function(h)
    if h.Parent:FindFirstChild("Humanoid") then
        local char = h.Parent
        local plr = game.Players:GetPlayerFromCharacter(char)
        if plr.leaderstats.Recourse.Value >= 10 then
            if db == false then
                db = true
                plr.leaderstats.Recourse.Value -= 10
                print("worked")
                local ab = {script.Parent.Parent.Parent.AvailableSpots:GetChildren()}
                for i, v in pairs(ab) do
                    if v.Occupied == false then
                        print("occupied is false")
                        local clone = game.ReplicatedStorage.GrassDum:Clone()
                        print("it cloned")
                        clone.Parent = workspace
                        print("workspaceparent")
                        clone:MoveTo(v.Position)
                        print("it shud work since it moved to pos")
                    end
                    wait(2)
                    db = false

                end
            end
        end
    end
end)

2 answers

Log in to vote
0
Answered by 1 year ago

I believe that :MoveTo() is deprecated. I’ve used it before and its always given me problems. Try just setting the cords instead.

0
you see i cant just set the pos to the spawn part, since it is a model. I will try looking for another way to move a model. I think if i set a primary part it can also work but thx for this i might approve it if the problem was :MoveTo() wswswff 39 — 1y
Ad
Log in to vote
0
Answered by 1 year ago

If MoveTo() isn't working, try the newly added feature PivotTo()

PivotTo() works the same as SetPrimaryPartCFrame except you don't need a primarypart.

clone:PivotTo(v.Position)

0
wsg so it turns out that idk so yeah um i fixed it somehow but now im onto another error wswswff 39 — 1y

Answer this question