Why is this medkit script not healing or working? (its a serverscript)
Sccript:
script.Parent.Activated:Connect(function()
if PlayedSound ~= true then
script.Parent.Sound:Play()
PlayedSound = true
end
local player = script:FindFirstAncestorWhichIsA("Player") or game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)
local Char = player.Character or player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")
if Humanoid.Health >= 25 then
Humanoid.Health += 75
else
Humanoid.Health = 100
end
wait()
PlayedSound = false
script.Parent:Destroy()
end)
is this in a tool? if so, i’m pretty sure it needs to be a localscript
Tool scripts won’t run when they are in the player’s backpack before they are equipped for the first time. Here is a solution to fix this:
local Tool = script.Parent
local Character, Player, Humanoid
Tool.Activated:Connect(function()
--Code
end)
Tool.Equipped:Connect(function()
Character = Tool.Parent
Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
Humanoid = Character:FindFirstChildOfClass("Humanoid")
end)
I don’t want the player to look like they are healed but on others screens they are still low on health.
This doesn’t work umm Idk what to do
Forummer
(Forummer)
February 24, 2022, 1:07pm
#6
Can you drop the model file here?
Its not a free model um the script to make it work is up there.
there’s no point on adding a if statement if in other else statement will still make it max health so yeah, just
MrGameboy123456789:
Humanoid.Health = 100
No I am wanting the player to gain 75 health and if the player health is 25 or under.
Forummer
(Forummer)
February 24, 2022, 1:23pm
#10
That’s not the entire script though.
The rest script is variables. not anything else its a serverscript in a tool
apparently, you used greater than so anything that it is greater than 25 it will added to 75 equals to 100. use <=
instead
nope not working umm anything else?
Can you explain further on what’s really not working? The healing? Or all of it? Because if you heard a sound then it may be the healing
all of it most likely because if the healing isn’t working then all of its not working.
Chocolauf
(Laufeyson)
February 24, 2022, 3:25pm
#16
it’s not working because it’s a serverscript
Hi I figured out that it was because roblox default startercharacterscript “Health” was causing it!