Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't the clone I made showing up in the Workspace?

In the script, the name of the Clone's parent isn't printing, and the clone isn't in Workspace. Please help me.

script.Parent.RedFlag.Handle.Touched:Connect(function(char) 
    if char ~= nil then 
        local player = game.Players:GetPlayerFromCharacter(char.Parent) 
        if player ~= nil then 
            if char.Parent:FindFirstChild("Humanoid") then 
                if char.Parent:FindFirstChild("Humanoid").Health ~= 0 then 
                    print(player.Name .. " has the Red Flag!")
						if char.Parent:FindFirstChild("Humanoid").Health == 0 and char.Parent:FindFirstChild("RedFlag")then
							local FlagClone = game.ServerStorage:FindFirstChild("RedFlag"):Clone()
							FlagClone.Parent = game.Workspace
							print(FlagClone.Parent.Name)							
					end                    
                end
            end
        end
    end
wait(2)
end)

5 comments

0

is the game FE and is this a regular script or localscript

0

A regular script and what is FE?

0

You have not defined flag clone as a variable

0

FE stands for FilteringEnabled and you can check if it's on by looking at the properties of workspace

0

It is false

3 answers

A possible reason the clone has not been created, is that the service was not created yet using GetService. To fix this, you can do

local FlagClone = game:GetService('ServerStorage').RedFlag:Clone()
FlagClone.Parent = workspace

Otherwise, I do not know why it would not be cloning.

2 comments

0

Ok lemme try it out

0

Sorry, I have tried it out and it didn't work

The problem might have been you needed to use GetService and WaitForChild.

script.Parent.RedFlag.Handle.Touched:Connect(function(char) 
    if char ~= nil then 
        local player = game.Players:GetPlayerFromCharacter(char.Parent) --get player
        if player then  --if player
            if char.Parent:FindFirstChild("Humanoid") then --if humanoid
                if char.Parent.Humanoid.Health ~= 0 and char.Parent:FindFirstChild("RedFlag") then 
                    print(player.Name .. " has the Red Flag!")
			if char.Parent.Humanoid.Health == 0 then --if someone was killed on the flag then
                            local FlagClone = 		
game:GetService("ServerStorage"):WaitForChild("RedFlag"):Clone() 
                            FlagClone.Parent = workspace     
			end                                      
                end
            end
        end
    end
wait(2)
end)

Please accept my answer if this helped!

16 comments

0

No, sorry yours doesn't work

0

I tested it and it works 100%. How is it not working?

0

Yes that script works, but I want to make it so that when the player with the flag dies, the flag creates a clone of itself, not when they grab the flag

0

Then add a statement that kills the player

0

Because you used an if statement to see if the player's health was 0. You never set it directly to 0.

0

So then what should i do?

0

Here. Let me edit it for you.

0

What I'm going for is when the player dies, they drop the flag so that another player can pick it up

0

Done.

0

lemme try it out

0

I don't want it to kill me right when I touch the flag.

0

I see. Just updated it. Try it now.

0

I just tried it and it didn't work, the flag didn't clone

0

Please help me

0

Because it checks to see if the player has died when it touches the flag.

0

So then what should I do?

you should create a seprate local script that wait till they dies and checks if they have the flag then send a message to the server (with remote event) to say to create the flag again

3 comments

0

I added an if statement to mine bc I wanted to make it so that when the player dies with the flag, the flag creates a clone of itself.

0

He did do that, you are just pointing out what everything does.

0

Sorry, I'm really not that advanced in scripting, i just started out like 2 weeks ago

This discussion is preserved as it was. New answers, comments, and votes are closed.