Newbie scripter would like some help

Hey there. I’m a newbie programmer and i don’t know roblox programming very well.

I’m practicing random stuff with the goal of making what i printed appear in the output
i was in doubt and asked chatgpt, and he sent me this.
image

it doesn’t appear in the output,. Tbh, i really don’t know what are those events lol, Anyways, this script’s parent is Workspace.

4 Likes

the code that you have made is a bit wrong because you made a variable which accepts a string which is formatted like: “string”.
if you want to check if algo is false then change it to local algo = false
also about the event, touched event is used for when character touches a part.

4 Likes

why are you connecting a touched event to the script

2 Likes

it needs to be in the fuction or on the first line or on the function? ( just for sure)

oh, okay, thanks a lot!

2 Likes

when variable starts with “local”: it should be on the top of your code.
i’ve modified your code so it would be simple to read (you can run that!):

local Algo = false -- Boolean (false/true)

local function Deal()
    Algo = true -- Algo is now true
	print("Algo is now "..Algo.."! Yipee") -- This function outputs string (basically, prints) that has value from boolean Algo in developer console (F9)
end

script.Touched:Connect(function()
	Deal() -- Call a function to set Aglo to true
	if Algo == false then -- Checks if Algo is certainly false (however, function changed it to true lol)
		print("Algo was false all the time!") -- Printing if Algo was false
	else -- Runs another part of the code if Algo is something else
		print("Algo was true all the time!") -- Printing if Algo was true
	end
end)
2 Likes

Thank you for the solution!

i really aprecciate it

2 Likes

glad that this helped in your progression on being a programmer!

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.