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

How would I make this script work with a certain model?

Asked by
Lodok3 18
4 years ago

This question has been solved by the original poster.

So I am trying to make a building system, with snapping, but the snap parts are not deleted when I fire the script, can anyone help me?

for _,q in pairs(game.Workspace:GetDescendants()) do
    if q:IsA("Part") then
        for _,s in pairs(game.Workspace:GetDescendants()) do
            if s:IsA("Part") then
                if s.Position == q.Position and s~= q then
                    if string.sub(s.Name,1,1) == "e" and string.sub(q.Name,1,1) == "SP" then
                        q:Destroy()
                    elseif string.sub(q.Name,1,1) == "e" and string.sub(s.Name,1,1) == "SP" then
                        s:Destroy()
                    else
                        local r= math.random(0,1)
                        if r== 0 then
                            s:Destroy()
                        else
                            q:Destroy()
                        end
                    end
                end
            end
        end
    end
end

the place is on my profile, its called "Random Testing Environment"Link

0
oh i forgot to say run the code in command line Lodok3 18 — 4y
0
and the script deletes parts overlapping each other Lodok3 18 — 4y
0
whats with the substring stuff? Also you are checking if one character is equal to 2 characters while also being equal to another different character, so that's probably your problem there SteamG00B 1633 — 4y
0
substring means it checks the character, in this case it is checking the first character of the string, hence why it is substring(q.Name,1,1)) Lodok3 18 — 4y
View all comments (3 more)
0
oh sorry, i will change the code Lodok3 18 — 4y
0
string.sub(q.Name,1,1) == "SP" that will always return false because one character is not equal to 2 SteamG00B 1633 — 4y
0
i found the error, the parts where on the same pos, but it was misaligned by 0.00005 studs Lodok3 18 — 4y

Answer this question