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

My game keeps crashing and lagging??? Why?? (I think it is a script)

first of all the game lags when it runs this script it lags at timer 1 (HELP)

timer = script.Parent
val = game.ReplicatedStorage.Timer
intro = game.ReplicatedStorage.Intro


while true do
	if intro.Value == 1 then
		wait(1)
		timer.Text = val.Value
		val.Value = val.Value - 1
	end
	if val.Value == 0 then
		intro.Value = 0
		timer.Visible = false
	end
end

and my game will also only do this function once (arrows point to the functions)

local gamie = game.ReplicatedStorage.Game
local intro = game.ReplicatedStorage.Intro
local ct = game.ReplicatedStorage.CorruptedTimer
local timer = game.ReplicatedStorage.Timer
baseplate = game.Workspace.Model.Baseplate
lava = game.ReplicatedStorage.Lava
jv = game.ReplicatedStorage["Jason Vorhees"]

gamie.Changed:Connect(function()
	if gamie.Value == 5 then
		if jv.Parent == game.ReplicatedStorage then -- this one
			jv.Parent = game.Workspace -- this one
		end
	end 
	if gamie.Value == 2 then
		timer.Value = 20
		intro.Value = 1
		ct.Value = 20 
		if baseplate.CanCollide == true then
			baseplate.CanCollide = false
		end
		wait(5)
		if baseplate.CanCollide == false then 
			baseplate.CanCollide = true
		end
		if jv.Parent == game.Workspace then -- this one
			jv.Parent = game.ReplicatedStorage - this one
		end
		gamie.Value = 1
		if lava.Parent == game.ReplicatedStorage then 
			lava.Parent = game.Workspace
		end
		wait(1)
		if lava.Parent == game.Workspace then
			lava.Parent = game.ReplicatedStorage
		end
	end
end)

1 answer

Because you have no wait for one side, it will wait for the one then the other side it will run as fast as possible


timer = script.Parent
val = game.ReplicatedStorage.Timer
intro = game.ReplicatedStorage.Intro


while true do
    wait(1)
    if intro.Value == 1 then
        timer.Text = val.Value
        val.Value = val.Value - 1
    end
    if val.Value == 0 then
        intro.Value = 0
        timer.Visible = false
    end
end

As the other script idk what causing that just yet, I’ll look a little more though

8 comments

0

ok thank you soo much

0

I really don’t get your second script, it makes not a lot of sense. All you’re doing all the way down the script is switching a parent back and forth.

0

ik and the script that u answered didnt work it didnt activate another script

0

ik and the script that u answered didnt work it didnt activate another script

0

Makes no sense lol, all I did was change a wait to make the entire loop wait rather than one line, should work the exact same as nothing major was changed

0

Only reason it wouldn’t work is you gave me a script that was flawed from the start

0

no it wasnt it worked okay from the start

0

Okay well hopefully someone can fix it for you

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