game.ReplicatedStorage.ColaDrank.OnServerEvent:Connect(function(plr,itemname)
if plr.Character.Humanoid.Health <= 99 then
plr.Character.Humanoid.Health = plr.Character.Humanoid.Health - 10
plr.Character.Humanoid:UnequipTools()
wait(1)
plr.Backpack[itemname]:Destroy()
end
end)
Custom health script :
-- Gradually regenerates the Humanoid's Health over time.
local REGEN_RATE = 1/100 -- Regenerate this fraction of MaxHealth per second.
local REGEN_STEP = 10 -- Wait this long between each regeneration step.
--------------------------------------------------------------------------------
local Character = script.Parent
local Humanoid = Character:WaitForChild'Humanoid'
--------------------------------------------------------------------------------
while true do
while Humanoid.Health < Humanoid.MaxHealth do
local dt = wait(REGEN_STEP)
local dh = dt*REGEN_RATE*Humanoid.MaxHealth
Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
end
Humanoid.HealthChanged:Wait()
end
i think the event is firing fast.that kills player instant.have you added a DB? (prevents spams) if u didnt adding it to the local script that fires event is best choice.
will it be ok if i send the script thats firing to you?
if ok :
local toolequipped = false
local UserInputService = game:GetService("UserInputService")
local Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
local Animation = script.BloxyCola
local Track = Humanoid:LoadAnimation(Animation)
local usable = true
while true do
if usable == true then
if script.Parent.Equipped then
toolequipped = true
elseif script.Parent.Equipped == false then
toolequipped = false
end
UserInputService.InputEnded:Connect(function(io)
if io.UserInputType == Enum.UserInputType.MouseButton1 then
if toolequipped then
if Humanoid.Health <= 99 then
usable = false
Track:Play()
wait(1)
Track:Stop()
game.ReplicatedStorage.ColaDrank:FireServer(script.Parent.Name)
end
end
end
end)
end
wait()
end
local toolequipped = false
local UserInputService = game:GetService("UserInputService")
local Humanoid = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid")
local usable = true
local debounce = false
while true do
if usable == true then
if script.Parent.Equipped then
toolequipped = true
elseif script.Parent.Equipped == false then
toolequipped = false
end
UserInputService.InputEnded:Connect(function(io)
if io.UserInputType == Enum.UserInputType.MouseButton1 then
if toolequipped then
if Humanoid.Health <= 99 then
usable = false
wait(1)
if debounce == false then
debounce = true
game.ReplicatedStorage.ColaDrank:FireServer(script.Parent.Name)
task.wait(1)
debounce = false
end
end
end
end
end)
end
wait()
end