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)
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