-- Module script
function AnimationHandler.MarkerReached(AnimationName, AnimationData, Callback)
AnimationName = (typeof(AnimationName) == "string" and AnimationName) or warn(INVALID_ANIMATION_ERROR)
if not AnimationHandler[Character.Name].LoadedAnimations[AnimationName] then return end
local Track = AnimationHandler[Character.Name].LoadedAnimations[AnimationName]
Track:GetMarkerReachedSignal(AnimationData):Connect(function() Callback:InvokeServer() end)
end
-- Client script
local AnimationSettings = {
["Play"] = function(AnimationName, AnimationData)
AnimationManager.PlayAnimation(AnimationName, AnimationData)
end,
["MarkerReached"] = function(AnimationName, AnimationData, Callback)
AnimationManager.MarkerReached(AnimationName, AnimationData, Callback)
end,
["Stop"] = function(AnimationName, AnimationData)
AnimationManager.StopAnimation(AnimationName, AnimationData)
end,
["LoadAnimations"] = function(Character, ClassNames)
AnimationManager.LoadAnimations(Character, ClassNames)
end,
}
AnimationRemote.OnClientEvent:Connect(function(AnimationName,Task,AnimationData,Callback)
AnimationSettings[Task](AnimationName,AnimationData,Callback)
end)
-- Server script
function Callback.OnServerInvoke(Player)
print("It worked")
end
AnimationRemote:FireClient(Player, "Reversal Red", "MarkerReached", "fire", Callback)
SussyZets
(SussyZets)
November 30, 2023, 10:09am
#43
Thank you bro, it finally worked, but what should I do if I need different function for every marker and different skill, i canāt just go on making different remotes? Also sry for making u code everything.
Np, Iām glad to help you
No, the only solution is to create different remotes. But you can make a āmacroā:
function remote(callback)
remoteFunction = Instance.new("RemoteFunction")
function remoteFunction.OnServerInvoke(player)
callback()
end
remoteFunction.Parent = ReplicatedStorage
return remoteFunction
end
-- usage
event:FireClient(player, data1, data2, remote(function()
print("action1")
end))
event:FireClient(player, data3, data4, remote(function()
print("action2")
end))
SussyZets
(SussyZets)
November 30, 2023, 11:49am
#45
Yo, on youtube i found someone who has a similar framework as me.
He did this on the serverhandler script:
rp.Server.OnServerInvoke = function(player,Cparams)
local char = player.Character
local root = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
local params = {
player = player,
root = root,
hum = hum,
}
require(script[Cparams.Name.."Server"])[Cparams.Function](params, Cparams)
end
And this on a localscript:
rp.Server:InvokeServer({Name = "ExampleScript", Function = "ExampleFunction"})
Wouldnāt something like this also work?
Yes, it would. There are many ways to do this.
SussyZets
(SussyZets)
November 30, 2023, 1:27pm
#47
And what would be the best way to do it?
I donāt know. You can try different methods and find out by yourself.
SussyZets
(SussyZets)
November 30, 2023, 2:17pm
#49
Ok, tho thereās one last thing I would like to ask you , all the abilities are stored in module scripts, so how I āsendā the āremoteā function to a modulescript?
SussyZets
(SussyZets)
November 30, 2023, 2:22pm
#51
So this has to be on the server script right?
But this need to be in a module script:
event:FireClient(player, data1, data2, remote(function()
print("action1")
end))
event:FireClient(player, data3, data4, remote(function()
print("action2")
end))
Is it not possible?
SussyZets
(SussyZets)
November 30, 2023, 2:23pm
#52
Also, why does the animation manager module script use remotes, wouldnāt it just be better to require the module script instead?
It is possible. You just move this into a module script.
I donāt knowā¦ You made this system.
SussyZets
(SussyZets)
November 30, 2023, 2:38pm
#55
Sadly, I didnāt. Donāt you think i would be able to fix the issue on my own?
Yes, however I donāt see any issues with this solution.
SussyZets
(SussyZets)
November 30, 2023, 2:48pm
#57
itās finally working, i can continue making my game, and thanks to you I learned a lot about remotes. TYSM!!!
1 Like
SussyZets
(SussyZets)
November 30, 2023, 2:48pm
#58
Also thank you, for tying to help me.
system
(system)
Closed
December 14, 2023, 2:49pm
#59
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.