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

When Cloned, script somehow does not change any values (Still not Working)?

I have made a script to clone this script into a NumberValue, however, it never runs. It is disabled, cloned from Lighting into a value, then enabled so it can run. Here is the script:

--ServerScript
while true do
	wait(5)
	if script.Parent.Value >= 1 then
	script.Parent.Value = script.Parent.Value - 1
	else
	repeat 
	wait(2)
	script.Parent.Parent.DogeHealth.Value = script.Parent.Parent.DogeHealth.Value - 1
	until script.Parent.Parent.DogeHealth.Value == 0
	end
end
while true do
	wait(5)
	if script.Parent.Parent.DogeHealth.Value == 0 then
	local Player = script.Parent.Parent.Parent
	game.workspace[Player.Name.."Dog"].DogeMesh.VertexColor = Vector3.new(255,0,0)
	game.workspace[Player.Name.."Dog"].Anchored = true
	else
		local Player = script.Parent.Parent.Parent.Name
		game.workspace[Player.Name.."Dog"].VertexColor = Vector3.new(255,255,255)
		game.workspace[Player.Name.."Dog"].Anchored = false
	end
end

1 answer

Your problem here is that you have two infinite loops running in the same script, this means that the 'while true do' loop below the first never runs.

You should put this in one script:

while true do
    wait(5)
    if script.Parent.Value >= 1 then
    script.Parent.Value = script.Parent.Value - 1
    else
    repeat
    wait(2)
    script.Parent.Parent.DogeHealth.Value = script.Parent.Parent.DogeHealth.Value - 1
    until script.Parent.Parent.DogeHealth.Value == 0
    end
end

and this in another:

while true do
    wait(5)
    if script.Parent.Parent.DogeHealth.Value == 0 then
    local Player = script.Parent.Parent.Parent
    game.workspace[Player.Name.."Dog"].DogeMesh.VertexColor = Vector3.new(255,0,0)
    game.workspace[Player.Name.."Dog"].Anchored = true
    else
        local Player = script.Parent.Parent.Parent.Name
        game.workspace[Player.Name.."Dog"].VertexColor = Vector3.new(255,255,255)
        game.workspace[Player.Name.."Dog"].Anchored = false
    end
end

Hope this helped! If you have anymore problems message me on roblox.

2 comments

0

Oh. I thought they would run seperatly. Thanks!

0

Wait, it still is not working. I don't know whats wrong with it.

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