Been waiting days. but no one answered my old post so made a new one. This script stops running after the client invoke thing.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Humanoid.Parent:WaitForChild("HumanoidRootPart")
local RemoteFunction = script.Parent.RemoteFunction
local RP = game:FindService("ReplicatedStorage")
local Event = RP.InAir
-----------Animations---------------------
--//Ani 1 (Defualt)//--
local Animation = script.DefualtSwing
local AnimationTrack = Humanoid:LoadAnimation(Animation)
--//Ani 2 (T-Pose)//--
local Animation2 = script.TPoseSwing
local Animation2Track = Humanoid:LoadAnimation(Animation2)
--// Ani 3 (UpsideDown)//--
local Animation3 = script.UpsideDown
local Animation3Track = Humanoid:LoadAnimation(Animation3)
-------------------------------------------
local RopeAmount = Player:WaitForChild("NumberOfHooks"):WaitForChild("Amount")
local EventDB = false
Event:FireServer()
game:GetService("RunService").Stepped:Connect(function()
RemoteFunction.OnClientInvoke = function(player,data,TPoseEquipped,TPoseOwned,GoldenHookEquipped,GoldenHookOwned) --Wont run past here
if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if RopeAmount.Value == 1 then
local char = Player.Character
if data == nil then
if TPoseEquipped.Value == false then
AnimationTrack:Play()
AnimationTrack.Looped = true
end
else
if TPoseEquipped.Value == true then
Animation2Track:Play()
Animation2Track.Looped = true
elseif TPoseEquipped.Value == false then
AnimationTrack:Play()
AnimationTrack.Looped = true
end
end
elseif RopeAmount.Value == 0 then
if data == nil then
if TPoseEquipped.Value == false then
AnimationTrack:Stop()
end
else
if TPoseEquipped.Value == true then
Animation2Track:Stop()
elseif TPoseEquipped.Value == false then
AnimationTrack:Stop()
end
end
end
end
end
wait(.5)
end)
Hello, I am not 100% sure If this fixes the issue but you should separate the OnClientInvoke function from the Stepped event.
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Humanoid.Parent:WaitForChild("HumanoidRootPart")
local RemoteFunction = script.Parent.RemoteFunction
local RP = game:FindService("ReplicatedStorage")
local Event = RP.InAir
-----------Animations---------------------
--//Ani 1 (Defualt)//--
local Animation = script.DefualtSwing
local AnimationTrack = Humanoid:LoadAnimation(Animation)
--//Ani 2 (T-Pose)//--
local Animation2 = script.TPoseSwing
local Animation2Track = Humanoid:LoadAnimation(Animation2)
--// Ani 3 (UpsideDown)//--
local Animation3 = script.UpsideDown
local Animation3Track = Humanoid:LoadAnimation(Animation3)
-------------------------------------------
local RopeAmount = Player:WaitForChild("NumberOfHooks"):WaitForChild("Amount")
local EventDB = false
Event:FireServer()
RemoteFunction.OnClientInvoke = function(player,data,TPoseEquipped,TPoseOwned,GoldenHookEquipped,GoldenHookOwned)
if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if RopeAmount.Value == 1 then
local char = Player.Character
if data == nil then
if TPoseEquipped.Value == false then
AnimationTrack:Play()
AnimationTrack.Looped = true
end
else
if TPoseEquipped.Value == true then
Animation2Track:Play()
Animation2Track.Looped = true
elseif TPoseEquipped.Value == false then
AnimationTrack:Play()
AnimationTrack.Looped = true
end
end
elseif RopeAmount.Value == 0 then
if data == nil then
if TPoseEquipped.Value == false then
AnimationTrack:Stop()
end
else
if TPoseEquipped.Value == true then
Animation2Track:Stop()
elseif TPoseEquipped.Value == false then
AnimationTrack:Stop()
end
end
end
end
end
game:GetService("RunService").Stepped:Connect(function()
-- Your other code that needs to run every frame
end)
This should fix the issue you were having and allow the OnClientInvoke function to work correctly.
the print doesnt even go through. I need to make it so it constantly knows when the player is in the air, and I think it only does it once, before the player even loads.
local Players = game:GetService("Players")
local RP = game:FindService("ReplicatedStorage")
local Event = RP.InAir
local RemoteFunction = script.Parent.RemoteFunction
Event.OnServerEvent:Connect(function(player)
print("3")
local DataManager = require(game:GetService("ReplicatedStorage").DataManager)
local data = DataManager:Get(player)
local TPoseEquipped = data.TPoseEquipped
local TPoseOwned = data.TPoseOwned
local GoldenHookEquipped = data.GoldenHookEquipped
local GoldenHookOwned = data.GoldenHookOwned
RemoteFunction:InvokeClient(data,TPoseEquipped,TPoseOwned,GoldenHookEquipped,GoldenHookOwned)
end)
Event.OnServerEvent:Connect(function(player)
print("3")
local DataManager = require(game:GetService("ReplicatedStorage").DataManager)
local data = DataManager:Get(player)
local TPoseEquipped = data.TPoseEquipped
local TPoseOwned = data.TPoseOwned
local GoldenHookEquipped = data.GoldenHookEquipped
local GoldenHookOwned = data.GoldenHookOwned
RemoteFunction:InvokeClient(player, data, TPoseEquipped, TPoseOwned, GoldenHookEquipped, GoldenHookOwned)
end)