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

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

Asked by 5 years ago
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

Log in to vote
0
Answered by
uhSaxlra 181
5 years ago

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))
Ad
Log in to vote
0
Answered by 5 years ago

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.

Answer this question