Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there any way to prevent Collison when using :MoveTo()? FE

Im trying to do an upgrade level so when you upgrade, it requires to move the model to required location, but my model floats in air, any suggestions? Please dont moderate this because im not requesting to do all for me, Im just asking is there any way!

-- V A R I A B L E S

local Player = game:GetService("Players").LocalPlayer
local Database = Player:WaitForChild("Database")

local ModelToBeMoved = game:GetService("Workspace"):WaitForChild("Blacksmith_Ruins")
local ModelToBeMovedActivator = game:GetService("Workspace"):WaitForChild("BSRuinsGUI_Link")
local ModelToBeMovedExitPart1 =  game:GetService("Workspace"):WaitForChild("BSShowPos")


local ModeToBeShown = game:GetService("Workspace"):WaitForChild("Blacksmith")

script.Parent.MouseButton1Click:Connect(function()
    if Database.Value_Inv.Plank_Value.Value >= 5 and Database.Value_Inv.Rock_Value.Value >= 10 and Database.Value_Inv.Stick_Value.Value >= 8 then
        Database.Value_Inv.Plank_Value.Value = Database.Value_Inv.Plank_Value.Value - 5
        Database.Value_Inv.Rock_Value.Value = Database.Value_Inv.Rock_Value.Value - 10
        Database.Value_Inv.Stick_Value.Value = Database.Value_Inv.Stick_Value.Value - 8
        ModelToBeMoved:MoveTo(Vector3.new(999, 999999, 999))
        ModelToBeMovedActivator:Destroy()
        ModeToBeShown:MoveTo(Vector3.new(539.177, 9.24, 133.762))
        local gui = script.Parent.Parent.Parent.Parent:WaitForChild("BSRuinsGUI")
    end
end)

2 comments

1

I believe MoveTo() moves the primarypart in a model, check under the models properties to see if it has one

0

Thanks, I will check

2 answers

✓ Accepted answer

###If you're trying to move a model inside a building with MoveTo, it will teleport up to the ceiling to prevent clipping through the walls. Set a PrimaryPart for your models and use SetPrimaryPartCFrame.

-- V A R I A B L E S

local Player = game:GetService("Players").LocalPlayer
local Database = Player:WaitForChild("Database")

local ModelToBeMoved = game:GetService("Workspace"):WaitForChild("Blacksmith_Ruins")
local ModelToBeMovedActivator = game:GetService("Workspace"):WaitForChild("BSRuinsGUI_Link")
local ModelToBeMovedExitPart1 =  game:GetService("Workspace"):WaitForChild("BSShowPos")


local ModeToBeShown = game:GetService("Workspace"):WaitForChild("Blacksmith")

script.Parent.MouseButton1Click:Connect(function()
    if Database.Value_Inv.Plank_Value.Value >= 5 and Database.Value_Inv.Rock_Value.Value >= 10 and Database.Value_Inv.Stick_Value.Value >= 8 then
        Database.Value_Inv.Plank_Value.Value = Database.Value_Inv.Plank_Value.Value - 5
        Database.Value_Inv.Rock_Value.Value = Database.Value_Inv.Rock_Value.Value - 10
        Database.Value_Inv.Stick_Value.Value = Database.Value_Inv.Stick_Value.Value - 8
        ModelToBeMoved:SetPrimaryPartCFrame(CFrame.new(999, 999999, 999))
        ModelToBeMovedActivator:Destroy()
        ModeToBeShown:SetPrimaryPartCFrame(CFrame.new(539.177, 9.24, 133.762))
        local gui = script.Parent.Parent.Parent.Parent:WaitForChild("BSRuinsGUI")
        -- What is this line here? ^
    end
end)

3 comments

0

Thank you incapaz for full code, btw that line is destroying a gui because this script is located in playergui

0

Use Player.PlayerGui, not 50 script.Parent's. You're welcome.

0

Thanks mate

Model:MoveTo() moves the model to the top of the parts it encounters. If you want to avoid this, use Model:SetPrimaryPartCFrame()

ModelToBeMoved:SetPrimaryPartCFrame(CFrame.new(999, 999999, 999))
ModelToBeMovedActivator:Destroy()
ModeToBeShown:SetPrimaryPartCFrame(CFrame.new(539.177, 9.24, 133.762))

(Note that you need to set a primary part of the model for it to work)

2 comments

0

copy

0

no lol i posted my answer 7 seconds after yours

This discussion is preserved as it was. New answers, comments, and votes are closed.