Hello! I haven't been able to find an answer to my question above so I decided to come here to try and get it solved.
I have an local animation script in StarterGui>Components>Viewmodel: Image
Inside the localscript there is some code which should make shotgun shells spawn near the slider:
function playShoot() if game.ReplicatedStorage:WaitForChild("Components").Events.GiveClientInfo.Value == true then -- "GiveClientInfo" is a Bool Value which I used to get data from server that the player clicked Hold:Stop() Shoot.Looped = false -- Making sure for no errors Shoot:Play() if Shoot:GetMarkerReachedSignal("Eject Shells") then local shell = rep.Components.Models.Shells.Union:Clone() shell.Parent= workspace["Ejected Shells"] shell.CFrame = weapon.Ejector.CFrame + Vector3.new(0 , 1.5, 0) game:GetService("Debris"):AddItem(shell, 6) end Hold:Play() end end
Here is the Animation Window where I set up the marker: Image
But when played (In studio play mode as well as actually playing it), it fires as soon as I click (the shell is supposed to clone when the animation where the slider is shown appears): GIF
This is my first time messing with animation tracks and animation markers.
If any more info is needed, I will edit the post to add those details as soon as I can. Thanks!
Major Details Edit: The comments in the script was wrong, GiveClientInfo is a bool value not a remote event, I got confused with REs with the same name format, this has been corrected.
You're using :GetMarkerReachedSignal()
incorrectly. That method returns a RBXScriptSignal
, which you might already be familiar with. Here's an example of how to use it correctly:
local markerReached = animationTrack:GetMarkerReachedSignal(markerName) markerReached:Connect(function(...) print('animation marker was reached!') end)
Every time the marker named markerName
is reached, the markerReached
event will fire. Check out the API reference, too.
[The question is already solved by Optikk, just giving the answer script for any other person with the same issue(?)]
Script:
local function animate() local shell = rep.Components.Models.Shells.Union:Clone() shell.Parent= workspace["Ejected Shells"] shell.CFrame = weapon.Ejector.CFrame + Vector3.new(0 , 1, 0) game:GetService("Debris"):AddItem(shell, 6) end function playShoot() if game.ReplicatedStorage:WaitForChild("Components").Events.GiveClientInfo.Value == true then Hold:Stop() Shoot.Looped = false -- Making sure for no errors Shoot:Play() Hold:Play() end end Shoot:GetMarkerReachedSignal("Eject Shells"):Connect(animate)
Note: My implementation of the :GetMarkerReached() was wrong and the method I was using stacks it, it has been fixed