Server

local function onCreatePartFired(player,on)
local char = player.Character
local hum = char.Humanoid    
local example=hum:LoadAnimation(script.Animation)
local charge = game.Workspace.Part.Charge
local nani = charge:Clone()
if on == "on" then
nani.Parent = char.UpperTorso    
example:Play()
wait(0.28)
example:AdjustSpeed(0)
elseif on == "off" then
print("hi")
nani:Destroy()    
example:Stop()    
example:AdjustSpeed(10)
end
end

game.ReplicatedStorage.Charge.OnServerEvent:Connect(onCreatePartFired)

Local

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("Charge")

function onKeyPress(inputObject,gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.C then
			createPartEvent:FireServer("on")
  
    end
end

function onKeyRelease(inputObject,gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.C then
	print("lol")
		createPartEvent:FireServer("off")
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputEnded:connect(onKeyRelease)

When the server gets the message that on == off then it prints hi but thats it none of the other things happen

3 comments

0

It would help if you posted the LocalScript code. And please indent your code it's extreeeemely messy.

0

Edited it !!!

0

Your code removes 'nani' and stops the example animation. You didn't put any code in there that will display something