Issue? I can’t seem to send a character Instance over NetRay.
So I noticed this when I updated my Netray from the old Deprecated NetRay 2.0 to this newer one and everything was working normally, however, I can’t pass my character instance and animation instance through my Player animator event.
The error is thrown by the Binary Encoder Script and it prints to the console
“[BE Dec] Inst fail: Workspace.SagePrismatic”
(Btw, when I click on this error, it’s leads to line 174 of the Binary Encoder script)
(Sorry if what I send is a bit too much/unnecessary but I’d rather send my whole code)
Here is the code for the Sever, I fire the event on line 59:
--Services
local ServerScriptService = game:GetService('ServerScriptService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local ServerStorage = game:GetService('ServerStorage')
--Debounce
local NPCDebounces = ServerStorage.Combat.NPCDebounces
local Debounces = ServerStorage.Combat.Debounces
--[Modules]
local PlayerAnimator = require(ServerScriptService.Modules.PlayerAnimator)
local HitboxCreator = require(ServerScriptService.Modules.HitboxCreator)
--Settings
local Settings = require(script.BasicAttackSettings)
local SUCCESS,FAIL,RUNNING = 1,2,3
--Attacks
local Attacks = {
Jab = Settings.Jab,
Cross = Settings.Cross,
Uppercut = Settings.Uppercut,
['Front Kick'] = Settings["Front Kick"]
}
--VFX
local HitEffects = ReplicatedStorage.ParticleEffects.Combat
local EmptyEffect = HitEffects.BlankEffect
local Task = {}
function Task.run(obj)
--Blackboard
local CurrentAttack = obj.Blackboard['NextBasicAttack']
local Blackboard = obj.Blackboard
--Setting variables for the character model
local Character = nil
local Player = nil
--Setting Player and Character
local NPCBool = Settings.CheckForNPC(obj)
if NPCBool == false then Player = obj.Player end
if NPCBool == false then Character = Player.Character else Character = obj.NPC end
local Humanoid = Character.Humanoid
--Attack Settings
local AttackSettings = Attacks[CurrentAttack]
--Setting Variables
local HitboxOffset = CFrame.new(AttackSettings.HitboxOffset)
local HitboxDuration = AttackSettings.HitboxDuration
local DebounceTime = AttackSettings.DebounceTime
local HitboxSize = AttackSettings.HitboxSize
local HitEffect = AttackSettings.HitEffect or HitEffects.RegularHit
local Damage = AttackSettings.Damage
local Anim = AttackSettings.Anim
local Attack = CurrentAttack
--⚠️⚠️Animate and Create the hitbox
PlayerAnimator.PushPlyrAnimations(Character, Anim) -- The Problem occurs when this is fired
HitboxCreator.CreateHitbox(Character, Attack, HitboxOffset, HitboxSize, HitboxDuration, Damage, HitEffect, false)
task.wait(DebounceTime)
--Debounce removal
if NPCBool == false then
Debounces:SetAttribute(tostring(Player.UserId), nil)
else
NPCDebounces:SetAttribute(Character.Name, nil)
end
--Setup for next attack
Humanoid:SetAttribute('NextSpecialAttack', AttackSettings.NextSpecialAttack)
Humanoid:SetAttribute('NextBasicAttack', AttackSettings.NextBasicAttack)
return SUCCESS
end
return Task
Then it goes to this module which fires to all clients: (This is most likely where the error occurs as it able to print the Character and animation before throwing an error)
--Services
local ReplicatedStorage = game:GetService('ReplicatedStorage')
--NetRay
local NetRay = require(ReplicatedStorage.Modules.NetRay)
--Event
local AnimationEvent = NetRay:RegisterEvent("PushPlyrAnimations", {
priority = NetRay.Priority.HIGH,
compression = true,
batchable = true,
rateLimit = {
MaxRequests = 1,
TimeWindow = 1,
BurstWindow = 1,
BurstLimit = 1,
}
})
local module = {}
--Pushes Animations to all clients.
--The "Player" Variable is the Player the Animation is being done on.
function module.PushPlyrAnimations(Character, Animation, LoopBool, Weight, WeightFadeTime, WeightAdjustStartTime)
print(Character)
print(Animation)
AnimationEvent:FireAllClients(Character, Animation, LoopBool or false, Weight or 0, WeightFadeTime or 0, WeightAdjustStartTime or 0)
end
return module
Then if it didn’t have an error it should fire to this Local script:
--Services
local ReplicatedStorage = game:GetService('ReplicatedStorage')
--NetRay
local NetRay = require(ReplicatedStorage.Modules.NetRay)
local PlayerAnimationEvent = NetRay:GetEvent("PushPlyrAnimations")
local function Animate(Character, Animation, LoopBool, Weight, WeightFadeTime, WeightAdjustStartTime)
local Humanoid = Character.Humanoid
local Animator = Humanoid:FindFirstChild('Animator')
local Anim = Animator:LoadAnimation(Animation)
Anim.Looped = LoopBool
Anim:Play()
if Weight > 0 then
task.wait(WeightAdjustStartTime)
Animation:AdjustWeight(Weight, WeightFadeTime)
end
end
PlayerAnimationEvent:OnEvent(function(Character, Animation, LoopBool, Weight, WeightFadeTime, WeightAdjustStartTime)
Animate(Character, Animation, LoopBool, Weight, WeightFadeTime, WeightAdjustStartTime)
end)
Additionally, I decided to do a quick test in another baseplate where I wait and then send my character through an event to the client where it will print the character’s name and this also resulted in the same error.
Test server script:
local NetRay = require(game:GetService('ReplicatedStorage').NetRay)
local Event = NetRay:RegisterEvent("ServerToClient")
task.wait(1)
Event:FireAllClients(workspace.SagePrismatic)
Test Client Script:
local NetRay = require(game:GetService('ReplicatedStorage').NetRay)
local Event = NetRay:GetEvent("ServerToClient")
Event:OnEvent(function(instance)
print(Instance.name)
end)