I'm trying to make a script where when the player pressed b they can spawn a certain model. And the model starts from the air and slowly comes down. But I don't know how to move the bricks at the same time.
My current script which I know wont work:
player = game.Players.LocalPlayer
mouse = player:GetMouse()
CanUse = true
mouse.KeyDown:connect(function(key)
-- Detects if keydown is pressed
if key == "b" then
CanUse = false
print ("spawning model....")
BG = game.Lighting.BegginerBricks:clone("BG")
BG.Parent = game.Workspace
BG.CFrame = player.Character.Torso.CFrame * CFrame.new(0,100,0)
for i = 100, 0, -.5 do
BG.CFrame = player.Character.Torso.CFrame * CFrame.new(0,i,0)
wait()
end
end
end)
Solved! to anybody who needs it here is my full working script.
player = game.Players.LocalPlayer
mouse = player:GetMouse()
CanUse = true
mouse.KeyDown:connect(function(key)
-- Detects if keydown is pressed
if key == "b" then
CanUse = false
print ("spawning model....")
BG = game.Lighting.BegginerBricks:clone("BG")
BG.Parent = game.Workspace
BG:SetPrimaryPartCFrame(player.Character.Torso.CFrame * CFrame.new(0,100,0))
PositionWhenCalled = player.Character.Torso.CFrame
for i = 100, 0, -.5 do
BG:SetPrimaryPartCFrame(PositionWhenCalled*CFrame.new(0,i,0))
wait()
end
end
end)

1 comment
To set a PrimaryPart you have to go on properties of the model, and change it's PrimaryPart manually. Or, you could do model.PrimaryPart = model.Part!