Hello guys, I recently wanted to create a stim that if you will use, it will give you infinite health, I made and script and animation. Due to my scripting issues aka. I can’t normally script or I can say I don’t even know how to script normally, it doesn’t work and output says nothing about the script, maybe because theres no printing about errors in the code.
The code:
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local hp = player.Character.Humanoid.Health
local animation = script.Parent:FindFirstChild("GDOAnim")
local injectAnimation = character.Humanoid:LoadAnimation(animation)
local inf = 99999999999999999999999999999999999999999999999
local canInject = true
local injection = 100
script.Parent.Activated:Connect(function(onClick)
if canInject then
canInject = false
injectAnimation:Play()
wait(injection)
hp = inf
if player.hp == inf then
print(player.Name .. ("used GDO-88 successfully."))
elseif player.hp == 100 then
print(player.Name .. ("used GDO-88 and failed."))
end
end
end)
I tried to recreate something from a guide, but it failed. Please help!
Humanoid:LoadAnimation() is deprecated use the animator of the humanoid
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local track = Animator:LoadAnimation(putanimobjecthere)
well um what do i do with this now if it doesnt work, i used roblox animator, not moon or anything else
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local track = Animator:LoadAnimation()
local animation = script.Parent:FindFirstChild("GDOAnim")
local hp = plr.Character.Humanoid.Health
local inf = 99999999999999999999999999999999999999999999999
local canInject = true
local injection = 3
local destroying = 60
script.Parent.Activated:Connect(function(onClick)
if canInject then
canInject = false
animation:Play()
wait(injection)
hp = inf
if plr.hp == inf then
wait(destroying)
print(plr.Name .. ("used GDO-88 successfully."))
elseif plr.hp == 100 then
print(plr.Name .. ("used GDO-88 and failed."))
end
end
end)
local Animator = humanoid:WaitForChild("Animator")
local animation = script.Parent:FindFirstChild("GDOAnim")
local track = Animator:LoadAnimation(animation)
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local animation = script.Parent:FindFirstChild("GDOAnim")
local track = Animator:LoadAnimation(animation)
local hp = plr.Character.Humanoid.Health
local inf = 99999999999999999999999999999999999999999999999
nothing happens, same with output, absolutely nothing
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local animation = script.Parent:FindFirstChild("GDOAnim")
local track = Animator:LoadAnimation(animation)
local hp = plr.Character.Humanoid.Health
local inf = math.huge
local canInject = true
local injection = 3
local destroying = 60
script.Parent.Activated:Connect(function(onClick)
if canInject then
canInject = false
animation:Play()
wait(injection)
hp = inf
if plr.hp == inf then
wait(destroying)
print(plr.Name .. ("used GDO-88 successfully."))
elseif plr.hp == 100 then
print(plr.Name .. ("used GDO-88 and failed."))
end
end
end)
You forgot to set canInject back to true or is that how you intended it?
Also why are you checking plr.hp and not hp?
You also need to update the health there
Here’s the fixed script:
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local animation = script.Parent:FindFirstChild("GDOAnim")
local track = Animator:LoadAnimation(animation)
local hp = plr.Character.Humanoid.Health
local inf = math.huge
local canInject = true
local injection = 3
local destroying = 60
script.Parent.Activated:Connect(function(onClick)
if canInject then
hp = humanoid.Health
canInject = false
animation:Play()
wait(injection)
hp = inf
if hp == inf then
wait(destroying)
print(plr.Name .. ("used GDO-88 successfully."))
elseif hp == 100 then
print(plr.Name .. ("used GDO-88 and failed."))
end
end
end)
Well, I don’t know if that doesnt let me inject but I think it dont let me before the animation, etc. But after you use the stim it should disappear until you respawn