I put a value called Clone1 and while in game, its actual value is 1 but the script is printing out 0.
Local Script in StarterPlayerScripts
local cloning = game.ReplicatedStorage.Cloning
local num = game.ReplicatedStorage.Cloning.Num
local limit = game.ReplicatedStorage.Limit
game.ReplicatedStorage.Clones.Clone1.Value = 0
game.ReplicatedStorage.Clones.Clone2.Value = 0
num.Value = 0
print(1)
while wait() do
if num.Value == 0 then
if game.ReplicatedStorage.Level.Value == 6 then
cloning.X.Value = 96
cloning.Y.Value = 0.5
cloning.Z.Value = -27
num.Value += 1
game.ReplicatedStorage.Clones.Clone1.Value = 1
cloning.Bandit_1:FireServer()
end
end
end
Script in Model
local humanoid = script.Parent.Parent.Humanoid
humanoid.MaxHealth = script.Parent.Health.Value
humanoid.Health = script.Parent.Health.Value
humanoid.WalkSpeed = script.Parent.Speed.Value
local hR = script.Parent.Parent:WaitForChild("HumanoidRootPart")
wait(0.1)
local main = hR.Parent
main.Archivable = true
hR.Anchored = true
local cloning = game.ReplicatedStorage.Cloning
cloning.Bandit_1.OnServerEvent:Connect(function()
print(game.ReplicatedStorage.Clones.Clone1.Value)
if game.ReplicatedStorage.Clones.Clone1.Value == 1 then
game.ReplicatedStorage.Clones.Clone1.Value = 0
print("Clone1")
local x = cloning.X.Value
local y = cloning.Y.Value
local z = cloning.Z.Value
local Clone = main:Clone()
Clone.Name = "1_Bandit"
Clone.HumanoidRootPart.Position = Vector3.new(x, y, z)
Clone.Humanoid.MaxHealth = script.Parent.Health.Value
Clone.Humanoid.Health = script.Parent.Health.Value
Clone.Humanoid.WalkSpeed = script.Parent.Speed.Value
Clone.Parent = main.Parent
Clone.HumanoidRootPart.Anchored = false
Clone.Hitbox.Anchored = true
if Clone.Humanoid.Health <= 0 then
wait(0.5)
Clone:Destroy()
end
end
end)
It prints as 0 even though I changed it to 1