I'm trying to make a system where I can play any player animations whenever I want without using weapons/equipment, but when I try to call a function inside a networked script from a client script in multiplayer preview mode, I get this error:
LocalPlayerBindingManagerScript:5: attempt to index a nil value (field 'context')
The two scripts work in normal Play mode.
First script:
local propNetworkAnimationScript = script:GetCustomProperty("NetworkAnimationScript"):WaitForObject()
local player = Game.GetLocalPlayer()
function OnBindingPressed(player, action)
propNetworkAnimationScript.context.AbilityAnimation(player, action)
end
player.bindingPressedEvent:Connect(OnBindingPressed)
Second script, networked and assigned to first scripts custom property:
local propUnarmed_Magic_Bolt = script:GetCustomProperty("Unarmed_Magic_Bolt")
local propOneH_Slash_Right = script:GetCustomProperty("OneH_Slash_Right")
function AbilityAnimation(player, action)
if (action == "ability_primary") then -- Mouse 1
-- Cast ability on 1
local ability = World.SpawnAsset(propUnarmed_Magic_Bolt)
ability.owner = player
player:GetAbilities()[1]:Activate()
ability:Destroy()
end
if (action == "ability_secondary") then -- Mouse 2
-- Cast ability on 2
local ability = World.SpawnAsset(propOneH_Slash_Right)
ability.owner = player
player:GetAbilities()[1]:Activate()
ability:Destroy()
end
if script.isNetworked then
print("It is networked!")
end
-- print(#player:GetAbilities()) Test to see if Abilities are deleted
end