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

How to set position of model?

Asked by 9 years ago

I made a script, it is for custom inventory picking up. When you go over an item it clones itself, goes to backpack, then removes itself... when equipping the item if you press the P button it clones itself to workspace, and removes itself. Unfortunately, I don't know how to set the model's position relevant to the player's! Here is my script

local tool = script.Parent
tool.Equipped:connect(function(mouse)
    mouse.KeyDown:connect(function(key)
        if key == "p" then
            local gitem = game.ReplicatedStorage.Pitchforkitem:clone()
            gitem.Parent = workspace
            gitem.Position = script.Parent.Parent.Torso.Position -- this part
            script.Parent:remove()
        end            
    end)
end)

Please help!!! Thank you!!!

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago
Model:MoveTo(Vector3 position)

This will teleport the model to the given position. If there are any obstructions in the way of that position then Roblox will automatically place the model on top of them.

Ad

Answer this question