Object not cloning

The object I have :Clone()'d simply will not go to the specified location, or any that I have tried.

I have tried setting the parent to multiple different locations, none work.

I have checked the locations and it has not appeared there.

local user = script.Daily:Clone();user.Parent = p;user.Next.Value = nextd;user.Void.Value = void;user.Days.Value = days;

– p is the function on join.


– Parts of the image blurred for security.

image
– Erroring when it tries to find it here:
image

If you need anything additional let me know.

This is because you are using the PlayerRemoving function, which fires right before/during the time the player is removed from the game. By time you are trying to get the player’s data, it is already gone. This is why people use DataStores (preferably DataStore2), and folders stored in the server to store data as they do not automatically delete upon a player leaving the game.

Source 1, and Source 2.

1 Like

Yes, okay. You didn’t read the part where I said no matter where I put it, the clone does not appear.

Be it workspace, server storage, lighting, nowhere. I was simply using the player to test.

Can you print the object and its parent into console after you parent it so we can see where the script thinks it is?

Yes, I attempted to do that, but it just doesn’t print. It seems like the script is ignoring the clone.

image
I used warn so it’d stand out.


image – Ignore the plugin errors.

Are you using .PlayerAdded? Sometimes you will load before the script, and out of good practice you should make a PlayerAdded function, loop through all existing players to fire the PlayerAdded, then hook the PlayerAdded event to the function. Example:

local Players = game:GetService("Players")

local function PlayerAdded(Player)
    print("Player has joined!", Player)
end

for _,v in pairs (Players:GetPlayers()) do
    PlayerAdded(v)
end

Players.PlayerAdded:Connect(PlayerAdded)

Here’s the full script.

**DB FUNCTION -- REMOVED**

game:GetService("Players").PlayerAdded:Connect(function(p)
	 **DB FUNCTION -- REMOVED**
		if not (Success) then
			warn("DATABASE DOWN. PLEASE REPORT TO DATABASE HEAD. [[PINKSARCASM,A_ROXN]]")
		elseif Value.Value == nil then
			print(p.Name.." does not have a daily.")
			game:GetService("ReplicatedStorage").LoaderReplicated.Donate:FireClient(p,"nodaily",0)
		else
            **DB FUNCTION -- REMOVED**
			local data = script.Daily:Clone()
			data.Parent = workspace
			data.Days = days
			data.Next = nextd
			data.Void = void
			
			warn(data.Parent)
			
			print("Loaded "..p.Name.."'s data.")
			wait(1)
			if tonumber(nextd) > os.time() and os.time() > tonumber(void) then
				game:GetService("ReplicatedStorage").LoaderReplicated.Donate:FireClient(p,"REDACTED",days)
			elseif tonumber(nextd) < os.time() then
				print(p.Name.." can not get daily yet.")
			elseif tonumber(nextd) > os.time() and os.time() < tonumber(void) then
				game:GetService("ReplicatedStorage").LoaderReplicated.Donate:FireClient(p,"REDACTED",days)
			end
		end
	end)
end)

game:GetService("Players").PlayerRemoving:Connect(function(p)
		local nextd = game:GetService("Players")[p.Name].Daily.Next.Value
		local void = game:GetService("Players")[p.Name].Daily.Void.Value
		local days = game:GetService("Players")[p.Name].Daily.Days.Value
		**DB FUNCTION -- REMOVED**
        **DB FUNCTION -- REMOVED**
        if not (Success) then
		print(ServerResponse)
	else
		print("AAAAAAAA")
		end
	end)
end)```

Try this out for testing.

local Players = game:GetService("Players") --Get Players so we don't keep indexing for it
local ReplicatedStorage = game:GetService("ReplicatedStorage") --Get ReplicatedStorage so we don't keep indexing for it

local LoaderReplicated = ReplicatedStorage:WaitForChild("LoaderReplicated") --Wait for whatever this is
local DonateRemote = LoaderReplicated:WaitForChild("Donate") --Wait for the donate remote

local function PlayerAdded(p) --Function for when player is added
	if not (Success) then
		warn("DATABASE DOWN. PLEASE REPORT TO DATABASE HEAD. [[PINKSARCASM,A_ROXN]]")
	elseif Value.Value == nil then
		print(p.Name.." does not have a daily.")
		DonateRemote:FireClient(p,"nodaily",0)
	else
		local data = script.Daily:Clone()
		data.Parent = p
		data.Days = days
		data.Next = nextd
		data.Void = void
		
		warn(data, data.Parent)
		
		print("Loaded "..p.Name.."'s data.")
		wait(1)
		if tonumber(nextd) > os.time() and os.time() > tonumber(void) then
			DonateRemote:FireClient(p,"REDACTED",days)
		elseif tonumber(nextd) < os.time() then
			print(p.Name.." can not get daily yet.")
		elseif tonumber(nextd) > os.time() and os.time() < tonumber(void) then
			DonateRemote:FireClient(p,"REDACTED",days)
		end
	end
end

Players.PlayerRemoving:Connect(function(p)
	local Daily = p:FindFirstChild("Daily") --Get the daily in the player, won't error if it's not there.
	
	if not Daily then
		error("Something has gone wrong, there's no daily in Player.") --Let us know something went wrong.
	end
	
	local nextd = Daily.Next.Value
	local void = Daily.Void.Value
	local days = Daily.Days.Value

    if not (Success) then
		print(ServerResponse)
	else
		print("AAAAAAAA")
	end
end)

for _,Player in pairs (Players:GetChildren()) do
	PlayerAdded(Player) --A player loaded before the code, call the function
end

Players.PlayerAdded:Connect(PlayerAdded) --Connect the script signal to the function we have

Ahh, I feel bad for saying this, but it still is not cloning the data.

And it didn’t warn the parent of the clone. I am not sure what is wrong here.

Most likely should have posted this before but.
image

Something in the redacted code must be yielding the script.

Big thank you to everyone who had replied.

Turns out it was an error with the way data was loading/saved. - All issues have been solved.

Thanks. :roblox_light: