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

How would I change the position of this model through a script?

local Cooldown = 10
local db = false
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
 	if db == false then
        db = true
game.Lighting.La:Clone().Parent = workspace
wait()
workspace.La.Position = plr.Character.Humanoid.Parent.Head
        for i = Cooldown, 0, -1 do
            wait(1)
            script.Parent.Text = "Cooldown: "..i
        end
    script.Parent.Text = "Spawn"
    db = false
    end
end)

Error: Position is not a valid member of Model

Any ideas?

2 answers

Roblox has a function for moving models, just as long as they have a primary part, which can be set in the properties of the model.

To move a model, just use SetPrimaryPartCFrame()

Example:

local head = plr.Character.Humanoid.Parent.Head
workspace.La:SetPrimaryPartCFrame(CFrame.new(Vector3.new(head.Position.X, head.Position.Y, head.Position.Z))

You need to use the method SetPrimaryPartCFrame to move models. For example:

workspace.La:SetPrimaryPartCFrame(plr.Character.Head.CFrame)
-- you need to set the primary part of the model first.

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