Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with script in First Aid kit, help with gaining health?

In the real server game, anyone can get the first aid kit which is not what I want. I am wanting if their health is lower than 90 then they are allowed to get the kit. It does work in studio though.

script.Parent.ClickDetector.MouseClick:connect(function(Clicker)
    Clicker = Clicker.Character 
    if Clicker.Humanoid.Health <= 90 then
	    Clicker.Humanoid.Health = Clicker.Humanoid.Health + 30 
	    for i,v in pairs {script.Parent.Parent} do
	        local Storage = game:GetService("ServerStorage"):WaitForChild("MedKitsStorage")
	        v.Parent = Storage
	        wait(60)
	        v.Parent = game.Workspace:WaitForChild("Storage")
	    end
	end
end)

5 comments

0

So people who have full health are able to get the medkit as well as people who have health lower than 90?

0

Yep

0

Idiot, why are you using the same name that you used for the plr argument, for the players character. Of course it's not going to work.

0

First, do something about those variables and maybe it'll work.

0

But the script works in studio... Idiot.

1 answer

✓ Accepted answer
debounce = false
script.Parent.ClickDetector.MouseClick:connect(function(Clicker)
    char = Clicker.Character --Try this.
    if char.Humanoid.Health <= 90  and debounce = false then
	debounce = true --Just to make sure that they don't keep clicking to gain practically instant-max 	health.
        char.Humanoid.Health = char.Humanoid.Health + 30 
        for i,v in pairs {script.Parent.Parent} do
            local Storage = game:GetService("ServerStorage"):WaitForChild("MedKitsStorage")
            v.Parent = Storage
            wait(60)
	    debounce = false
            v.Parent = game.Workspace:WaitForChild("Storage")
        end
    end
end)

Don't check things in Studio unless you're using server testing.

To check for errors in live-game, use F9.

Make sure this is a normal script and not a local script.

This discussion is preserved as it was. New answers, comments, and votes are closed.