Hi i tried to animate npc, but it returned after animation to its humanoid position so i thought i need to add mark and coresponding event. But all tutorials say put it in local script, but it is npc so it is on server and there is no client side (as far as i know), so animation played corectly, but the event was never called, silently without error
this is my code and it is placed into script its parent is npc root file
print(“ok”)
local ready=false;
while true do
if game.Lighting.ClockTime < 8 then
--print(game.Lighting.ClockTime,game.Lighting.ClockTime <8)
ready=true;
end
if game.Lighting.ClockTime >=8 and ready==true then
ready = false;
local an = workspace.Script.Mistr88.AnimSaves.ExportAnim --Instance.new("Animation");
--an.AnimationId="6867865bca81889ad6c3d53cfe174b07";
local a = workspace.Script.Mistr88.Humanoid:LoadAnimation(an)
print("now")
a.KeyframeReached:Connect(function(value)
print(value)
end)
a:Play();
end
wait(1);
end
this will run at 8am the animation
sry for my english and also sry for some stupid mistaces maded by copiing it from my studio to forum and from it to this forum xD (on the first forum it was long time without answer and this forum is quicker)
To be honest im not 100% sure what the question is but I think your asking how to check if time time is 8 on lighting and then to play an animation (may be wrong) but I made this script that does that
while wait(1) do
lighting = game:GetService(‘Lighting’)
if lighting.ClockTime == 8 then
anim = Instance.new(‘Animation’)
anim.AnimationId = ‘rbxassetid://31617132’
if script.Parent:FindFirstChild(‘Humanoid’) then script.Parent:FindFirstChild(‘Humanoid’):LoadAnimation(anim):Play() end
print(‘Its 8’)
end
end
this will check every second if the time is 8 and if it is will play an animation (would require additional checks to make sure it only played once but it shows the point
if this isn’t your question than please tell me.
and also you code can (no must but can) not work if i will make fast day time cicle because it can go thru 8 hours without activating this and also with slow cycle can activate 2times my code say if time it<than 8 get ready and if it is >=8 and i am ready, run code and unready
If you’re using markers, you need to use GetMarkerReachedSignal. As for animations, you can’t load an export like that, pretty sure. The AnimationId you commented out is invalid: publish your animation first and get the id.
so 1) i am sure i can load it because animation work
and 2) i tried keyframe and also marker event and no of them worked (GetMarkerReachedSignal and KeyframeReached)
You need to export the animation to ROBLOX and then make it private.
Try this code; make sure to add the asset ID!
if game.Lighting.ClockTime < 8 then
--print(game.Lighting.ClockTime,game.Lighting.ClockTime <8)
ready=true;
end
if game.Lighting.ClockTime >=8 and ready==true then
ready = false;
local an = Instance.new("Animation");
an.AnimationId=""; --Add the Roblox ASSET ID here
local a = script.Parent.Mistr88.Humanoid:LoadAnimation(an)
print("now")
a:Play();
a.KeyframeReached:Connect(function(value)
print(value)
end)
end
wait(1);
end
It seems as though you’ve never defined what the Keyframe’s name is? Its supposed to be more like this (basically identify if it reaches that certain keyframe)
YourAnimation(Probably a).KeyframeReached("TheKeyframe'sName"):Connect(function(Value)
-- Bla bla
print(Value) -- If you want
end)