Hey, I'm trying to make a hammer that has to be charged before being able to be swung. I'm in the knockback system part and this is what I've made with it so far...
Client:
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local rootPart = character:WaitForChild("HumanoidRootPart")
local remoteEvent = tool.RemoteEvent
local charge = script.Charge
local smash = script.Smash
local chargeTrack = animator:LoadAnimation(charge)
local smashTrack = animator:LoadAnimation(smash)
local cooldown = false
local charged = false
local canKnockback = false
local hanging = false
--local canKnockback = false
tool.Activated:Connect(function()
if not cooldown and not hanging then
cooldown = true
if not charged then
smashTrack:Stop()
chargeTrack:Play()
delay(chargeTrack.Length - 0.02999, function()
chargeTrack:AdjustSpeed(0)
end)
charged = true
end
wait(1)
cooldown = false
end
end)
tool.Deactivated:Connect(function()
chargeTrack:Stop()
if charged then
smashTrack:Play()
delay(smashTrack.Length - 0.02999, function()
smashTrack:AdjustSpeed(0)
rootPart.Anchored = true
hanging = true
wait(1)
smashTrack:Stop()
rootPart.Anchored = false
hanging = false
end)
remoteEvent:FireServer("charged")
charged = false
end
end)
Server:
local tool = script.Parent
local head = tool.Handle
local remoteEvent = tool.RemoteEvent
remoteEvent.OnServerEvent:Connect(function(canKnockback)
if canKnockback == "charged" then
head.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
local character = humanoid.Parent
local torso = character:WaitForChild("UpperTorso")
if humanoid then
torso.Transparency = 0.5
end
end)
end
end)
I'm new to RemoteEvents. Can someone explain what's going on here? Thanks much!

4 comments
Hello! Uhh, I did that and changed canKnockback to command so Line 06 looks like this now...
It still doesn't work tho.
The torso still becomes transparent even way before I've released.
Hm then there is a problem with your code