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
01local Cooldown = 10
02local db = false
03local plr = game.Players.LocalPlayer
04script.Parent.MouseButton1Click:Connect(function()
05    if db == false then
06        db = true
07game.Lighting.La:Clone().Parent = workspace
08wait()
09workspace.La.Position = plr.Character.Humanoid.Parent.Head
10        for i = Cooldown, 0, -1 do
11            wait(1)
12            script.Parent.Text = "Cooldown: "..i
13        end
14    script.Parent.Text = "Spawn"
15    db = false
16    end
17end)

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:

1local head = plr.Character.Humanoid.Parent.Head
2workspace.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:

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

Answer this question