Object not cloning

So im trying to check everytime when the player has a value that is equal to 8, if so it clones a shield onto the player, but it isn’t working why?

local shield = game.ReplicatedStorage.shield:Clone()

game.Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	shield.Parent = character
	local shieldIsOn = Instance.new("NumberValue", player)
	shieldIsOn.Name = "BulletHit"
	shieldIsOn.Value = 8
	local weld = Instance.new("WeldConstraint")
	while wait() do
		wait(1) 
		if player.BulletHit.Value < 8 then
			player.BulletHit.Value = player.BulletHit.Value + 1
		end
			if player.BulletHit.Value == 8 then --Starting from here it isn't working
			weld.Parent = character
			weld.Part0 = shield
			weld.Part1 = character.HumanoidRootPart
			shield.Position = character.HumanoidRootPart.Position
			shield:WaitForChild("IsInUse").Value = true
			end
	end
end)
1 Like

You need to do this:
shield.Parent = game.Workspace
Or:
shield.Parent = character

Edit: NVM just re-read the code

what do you mean? im not sure what i did wrong

1 Like

I’m looking into that right now.

In the docs the example code has the weld’s parent set to the Workspace. You might want to try that.

local weld = Instance.new("WeldConstraint")
weld.Parent = workspace
weld.Part0 = partA
weld.Part1 = partB

set the parent to workspace?

1 Like

Nope, that didn’t work. It just made my script break

Is the Shield not appearing at all?

no, the shield just stays there even when the shield is suppose to be destroyed when a value is set to 0

Does the shield get welded to the player?

no, it doesn’t

The way you have this script makes it so that the Shield instantly tries to weld to the player. Try using:

weld.Part1 = character:WaitForChild("HumanoidRootPart")

Screen Shot 2021-04-23 at 6.05.05 PM

Did you change anything else? This seems completely unrelated to what you modified.

Your script says that shield clones once, when new player added - no shield for him.

local shield = game.ReplicatedStorage.shield:Clone()
--Shield clone before PlayerAdded function
game.Players.PlayerAdded:Connect(function(player)

Try:

game.Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local shield = game.ReplicatedStorage.shield:Clone() --Put clone line here.
	shield.Parent = character
1 Like

Show me properties of your shield. If there’s Archivable and it’s set to false - set it to true, it should work.

1 Like

Screen Shot 2021-04-23 at 6.12.46 PM

Try this:

repeat
	shield.Parent = character
until shield.Parent == character

If you put a print() right after the Value == 8 does it print?