Currently I am trying to create a cosmic clone and I have made a script to copy the players position. I need to add a delay to when the rig follows the player. I have tried using task.delay() but whenever I use it with the loop, it exhausts the loop. Here is my current code:
local clone = game.ReplicatedStorage.Rig:Clone()
clone.Parent = workspace
local Player = script.Parent.Parent
local Character = Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
while true do
clone.HumanoidRootPart.CFrame = Root.CFrame
task.wait(0.01)
end
What i would do, first, get the player CFrame, wait, then set your cloone CFrame. and i would use a task.Spawn in order to have
not sure but i would have done it like this:
local clone = game.ReplicatedStorage.Rig:Clone()
clone.Parent = workspace
local Player = script.Parent.Parent
local Character = Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
While true do
Task.Spawn(Function()
local CRoot = Root.CFrame
Task.wait(0.01)
clone.HumanoidRootPart.CFrame = CRoot
end)
Task.Wait()
end
The loop is properly working and the rig does appear. The rig also follows the player but there is no delay between when the player moves and the rig moves so the rig is constantly at the exact position and orientation of the player.
If you want to have a 1 second delay, you have to change the task.wait(0.01) to 1.
the task.wait will is your delay.
Don’t touch the empty task.wait() since it’s here for the loop
A video would really be helpful.
in the “View” studio tab, you got a video recording button.
Then you can just upload it to youtube and share the link
I think you can just record it, convert the file from WMV (roblox video format, don’t ask why…) into a MP4, and just post it here like an image, should work
local clone = game.ReplicatedStorage.Rig:Clone()
clone.Parent = workspace
local Player = script.Parent.Parent
local Character = Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
While true do
Task.Spawn(Function()
local CRoot = Root.CFrame
Task.wait(1)
clone.HumanoidRootPart.CFrame = CRoot
end)
Task.Wait()
end