GetMarkerReachedSignal doesn't work

I want to make a flashlight open its light when a specific part of the animation plays but for some reason the flashlight doesn’t open.
I didn’t find anything in the devforum so I post this.

local Players = game:GetService("Players")
local flashlight = script.Parent

local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local openAnim = Instance.new("Animation")
openAnim.AnimationId = "rbxassetid://11684414273"
local OpenAnimTrack = animator:LoadAnimation(openAnim)

local HoldAnim = Instance.new("Animation")
openAnim.AnimationId = "rbxassetid://11684755470"
local HoldAnimTrack = animator:LoadAnimation(openAnim)

flashlight.Equipped:Connect(function() 
	OpenAnimTrack:Play()
	OpenAnimTrack.Stopped:Connect(function()
		HoldAnimTrack:Play()
	end)
	OpenAnimTrack:GetMarkerReachedSignal("Open"):Connect(function()
		flashlight.Light.SpotLight.Angle = 90
		flashlight.Light.SpotLight.Brightness = 3.12
		flashlight.Light.SpotLight.Range = 21
		end)
end)
2 Likes

I found a way to fix it. The thing I did wrong was changing all the angle and brightness stuff inside the script while I could just use enabled = true. Here is the script for anyone that wants it.

local Players = game:GetService("Players")
local flashlight = script.Parent

local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local openAnim = Instance.new("Animation")
openAnim.AnimationId = "rbxassetid://11684414273"
local OpenAnimTrack = animator:LoadAnimation(openAnim)

local HoldAnim = Instance.new("Animation")
openAnim.AnimationId = "rbxassetid://11684755470"
local HoldAnimTrack = animator:LoadAnimation(openAnim)

flashlight.Equipped:Connect(function() 
	OpenAnimTrack:Play()
	OpenAnimTrack.Stopped:Connect(function()
		HoldAnimTrack:Play()
	end)
	OpenAnimTrack:GetMarkerReachedSignal("Open"):Connect(function()
		flashlight.Light.SpotLight.Enabled = true

		end)
end)

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