Well the way I see it, you would like to damage player's when they are jumping, so you could do this two ways, one with a Remote Event which waits for the player to hit a SpaceBar and then damages them on the Server (this is because if they are damaged on the Client it will not replicated)
For this example, you will require a Local Script and a Server Script. The Local Script utilizes the UserInputService to determine what key the player presses
Server Script
local Remote = Instance.new("RemoteEvent")
Remote.Name = "PunishJump"
Remote.Parent = game:GetService("ReplicatedStorage")
Remote.OnServerEvent:Connect(function(player)
player.Character:WaitForChild("Humanoid"):TakeDamage(10)
end)
Local Script
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("PunishJump")
game:GetService("UserInputService").InputBegan:Connect(function(input, event)
if input.KeyCode == Enum.KeyCode.Space then
Remote:FireServer()
end
end)
You can also damage them on the Server by simply checking if they begin to jump with the HumanoidStateType "Jumping"
Server Script
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").StateChanged:Connect(function(old, new)
if new == Enum.HumanoidStateType.Jumping or character:WaitForChild("Humanoid").Jumping == true then
character:WaitForChild("Humanoid"):TakeDamage(10)
end
end)
end)
end)
However, this has the drawback of only not firing when the player continuously jumps
Another option you can do is to simply disable the player's ability to jump by setting the SetStateEnabled for Jumping to be false:
LocalScript
game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
My final suggestion is to set the CanCollide property of the "Part" (script.Parent) to false, which will make any player jumping on it fall through it, damaging them with the script you already have.
Otherwise: Revised Server Script
local Part = script.Parent
Part.CanCollide = false
local debounce = false
Part.Touched:Connect(function(touch)
local Hum = touch.Parent:FindFirstChild('Humanoid')
if debounce == true then return end
debounce = true
if Hum ~= nil then
Hum:TakeDamage(10)
wait(1)
end
debounce = false
end)
Since you are using FindFirstChild() you're original script would break if the result of this function was nil
2 comments
What script are you using :P Like put the script that wont work or you are trying to make work.
Im using the normal touched event Hum= touch.Parent:FindFirstChild(''Humanoid):TakeDamage(600) but none of it is firing