Detect if a videoframe is ended

Hi devs, i have a problem with video frames.When i play the video for the first time everything work but , when i re interact with the prox , the video don’t replay , does anyone know how to fix it?

Note : “VideoFrame.Ended:Wait()” ik its wrong but idk how detect when the video stopped , i tried with “VideoFrame.Ended:Connect(function()” but still didn’t worked.

Script :

local Prox = script.Parent
local VideoFrame = script.Parent.Parent.Parent.VideoPart.SurfaceGui.Hint
local ButtonColor = script.Parent.Parent.Parent.Televisor.BotonOUi.MeshPart



Prox.Triggered:Connect(function()
	

		Prox.Enabled = false
		ButtonColor.Color = Color3.fromRGB(78, 255, 14)
		VideoFrame.Visible = true
		VideoFrame.Playing = true
	script.Parent.Parent.Sparkles.Enabled = false
	
	VideoFrame.Ended:Wait()
	
		VideoFrame.Visible = false
	ButtonColor.Color = Color3.fromRGB(196, 40, 28)
	Prox.Enabled = true
	script.Parent.Parent.Sparkles.Enabled = true
	
end)
1 Like

Does anyone know how to fix that issue pls?

Instead of using wait do this:

VideoFrame.Ended:Connect(function()
	print("STOPPED")
    VideoFrame.Visible = false
	ButtonColor.Color = Color3.fromRGB(196, 40, 28)
	Prox.Enabled = true
	script.Parent.Parent.Sparkles.Enabled = true
end)

Some of the code might not be working because you have different levels of indentation under the function connected to the Prox.Triggered event. Make sure all indentation level is as appropriate.

Therefore:

local Prox = script.Parent
local VideoFrame = script.Parent.Parent.Parent.VideoPart.SurfaceGui.Hint
local ButtonColor = script.Parent.Parent.Parent.Televisor.BotonOUi.MeshPart



Prox.Triggered:Connect(function()
	Prox.Enabled = false
	ButtonColor.Color = Color3.fromRGB(78, 255, 14)
	VideoFrame.Visible = true
	VideoFrame.Playing = true
	script.Parent.Parent.Sparkles.Enabled = false
	
	VideoFrame.Ended:Wait()
	
	VideoFrame.Visible = false
	ButtonColor.Color = Color3.fromRGB(196, 40, 28)
	Prox.Enabled = true
	script.Parent.Parent.Sparkles.Enabled = true
	--this is the same script but all indentation has been fixed.
end)

Still not working , the “VideoFrame.Ended:Wait()” might be the prob

1 Like

Same it doesn’t work , after a second press on the prox when everything is ended the video don’t play and the print (“STOPPED”) get multiplied and multiplied ( : :arrow_forward: STOPPED (x153) - Serveur - Script:17 )

Could you send the script and a screenshot of where it is in the hierarchy/Explorer?

Script : 

local Prox = script.Parent
local VideoFrame = script.Parent.Parent.Parent.VideoPart.SurfaceGui.Hint
local ButtonColor = script.Parent.Parent.Parent.Televisor.BotonOUi.MeshPart



Prox.Triggered:Connect(function()
	Prox.Enabled = false
	ButtonColor.Color = Color3.fromRGB(78, 255, 14)
	VideoFrame.Visible = true
	VideoFrame.Playing = true
	script.Parent.Parent.Sparkles.Enabled = false

	VideoFrame.Ended:Wait()

	VideoFrame.Visible = false
	ButtonColor.Color = Color3.fromRGB(196, 40, 28)
	Prox.Enabled = true
	script.Parent.Parent.Sparkles.Enabled = true
	--this is the same script but all indentation has been fixed.
end)

and its in the Proximity prompt ( “local Prox = script.Parent” )

1 Like

Is it a server-side Script or a client-side LocalScript? Could you also send a screenshot of it in the Explorer?

1 Like

Its a server script and i told you its in the proximity prompt so in a model in the workspace

It’s quite hard to visualise where all the things are you mentioned in variables are without a screenshot, so I’m quite limited in helping you. In terms of the script, try changing VideoFrame.Ended:Wait() to VideoFrame.Ended:Connect(function() end) with the code inside of it. It would honestly be more efficient to have a LocalScript in StarterPlayerScripts to manage this so more than one client can use it at once.

Something that might be wrong (but I’m still not sure about) is that when you disable the ProximityPrompt it might disable the children of that ProximityPrompt too, therefore preventing the rest of the code from running.

Sounds like AI and indentation doesn’t change anything in luau!

1 Like

Nah actually the prob is from “VideoFrame.Ended:Wait()” i tried everything and it only work one time , after that the Ended will repeat and repeat

maybe try adding a return at the bottom line? to be honest I have never worked with VideoFrames so I don’t really know

I found the solution, in fact the videos don’t replay, so if you want to replay them, you have to set the “TimePosition” to 0.

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