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

Making a slideshow. How to disable one of a functions?

hi guys, i am a very beginner at scripting. I work with a regular script right now and there is my problems with code :

I'm making TV right now. It shows first nine slides (myFunction) but when player touched the part (Detector) i want myFunction to be disabled. How to disable first function? Is it even possible? I'm so confused... Please answer me, if there is any ways to solve this issue.

local Screen = script.Parent.Screen
local Slides = script.Parent.Slides
local Detector = script.Parent.Detector

function myFunction()
	while true do
	local Slide = 1
	for item, child in pairs(Slides:GetChildren()) do
		Screen.Slide.Texture = child.Texture
		Slide = Slide + 1
		if Slide >= 9 then
			wait(0.15)
			break
		end
		wait(0.15)
	end
end
end

myFunction()

local function onTouch(hit)
???????
end
Detector.Touched:connect(onTouch)

1 answer

Basically all this does is adds a boolean variable and checks if it's activated, and when it gets touched it will turn that variable off and break the while true do loop in 'myfunction':

local Screen = script.Parent.Screen
local Slides = script.Parent.Slides
local Detector = script.Parent.Detector

local activated = true

function myFunction()
    while true do
    if not activated then break end
    local Slide = 1
    for item, child in pairs(Slides:GetChildren()) do
        Screen.Slide.Texture = child.Texture
        Slide = Slide + 1
        if Slide >= 9 then
            wait(0.15)
            break
        end
        wait(0.15)
    end
end
end

myFunction()

local function onTouch(hit)
	activated = false
end
Detector.Touched:connect(onTouch)

3 comments

0

Thanks for attempt, but it still doesn't work...uh..i mean TV's still working

0

maybe put the if not activated line inside the for loop?

0

nope

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