I want it to spawn a part with Q keep moving the part around, and then if the user clicks the part will then anchor and no longer move, everything is being printed, nothing is moving, but all the part does is briefly spawn at 0, 0, 0 then despawn, help?
mouse = game.Players.LocalPlayer:GetMouse()
tool = script.Parent
spawned = false
final = false
function onKeyDown(key)
if key == "q" then
print ("Q was pressed")
if spawned == false then
local target = mouse.Target
q = game.Lighting.Beacon:Clone()
q.Parent = game.Workspace
q.Owner.Value = script.Parent.Parent.Name
q.Size = Vector3.new(3,3,3)
q.Anchored = false
q.CanCollide = false
spawned = true
print ("Checkpoint 1; passed")
while spawned do
wait()
q.CFrame = CFrame.new(Vector3.new(tool.Parent.Humanoid.TargetPoint.X,1,tool.Parent.Humanoid.TargetPoint.Z))
end
end
end
end
mouse.KeyDown:connect(onKeyDown)
function OnClick()
final = true
q.Anchored = true
end
mouse.Button1Up:connect(OnClick)
function onUnequipped()
q:remove()
spawned, final = false, false
end
script.Parent.Unequipped:connect(onUnequipped)
