So this will be a bit of long post just so you guys can get a good understanding of how i have this setup. Here is the game so you can go play it yourself and see the bugs. https://www.roblox.com/games/1209435230/PLAT-I-mean-TNI

So inside this tool, I have two local scripts, the main script which fires the remoteevent and handles what the tool is supposed to do. That script is here:


local player = game.Players.LocalPlayer
local playerMouse = player:GetMouse()
local debounce = true
local tool = script.Parent

tool.Equipped:connect(function()
	playerMouse.Button1Down:connect(function()
		local humanoid = player.Character.Humanoid
		if debounce == true and humanoid.Health < 100 then
			debounce = false
			humanoid.WalkSpeed = 0
			game.ReplicatedStorage.MediEvent:FireClient(player)
			wait(2)
			humanoid.WalkSpeed = 16
			humanoid.Health = humanoid.Health + 1
			wait(5)
			debounce = true
		end
	end)	
end)


The other script I have in this same tool is a weld script, I don't believe it'll have much effect here but I'll give it anyway:

local primary = script.Parent.Handle
local parts = script.Parent:GetChildren()

for i = 1, #parts do 
	if parts[i]:IsA("BasePart") or parts[i]:IsA("UnionOperation") then
		local weld = Instance.new("Weld")
		weld.Part0 = primary
		weld.Part1 = parts[i]
		weld.C0 = primary.CFrame:inverse()
		weld.C1 = parts[i].CFrame:inverse()
		weld.Parent = primary
		parts[i].CanCollide = false
	end
end

The third local script is located in StarterCharacterScripts, it handles the animation itself and receives the ClientInvoke. (The RemoteEvent itself is in ReplicatedStorage)

local player = game.Players.LocalPlayer
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=1213304793"
local animTrack = nil

function playMediAnim(Source)
		local player = game.Players.LocalPlayer.Character
		animTrack = player.Humanoid:LoadAnimation(animation) 
		animTrack:Play()
	end


game.ReplicatedStorage:WaitForChild("MediEvent").OnClientEvent:connect(playMediAnim)

A bit of explanation on what I mean by 'buggy':

  1. The player is floating in the air, he's supposed to be kneeling on the ground.

  2. Sometimes the animation partially plays, sometimes it doesn't play at all.

Sorry if this is this is hard to grasp or understand what I'm asking for, I can add more information on request in the comments.

Example of the 'floating': https://gyazo.com/e03f2d2d780b25edf8cd9d4beea1a5d2

2 comments

0

Is there a reason you can't just play the animation from the local script in the tool? The remote event there adds unnecessary complexity (as well as possible bugs) and is not needed.

0

I was playing it from the tool originally, I figured it could be a source of the bug so I switched it to a remoteevent. I'll switch it back