Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a onEquipped event on roblox?

Asked by
KenzaXI 166
8 years ago

Hi, I made this script,

-- Made by KenzaShadow --
local HealBall = script.Parent
function onEquip()
    local Player = game:GetService'Players'.LocalPlayer
    if (Player ~= nil) then
        Player.Humanoid.MaxHealth = 200
        wait(1)
        Player.Humanoid.Health = Player.Humanoid.MaxHealth
    end
end
HealBall.Equipped:connect(onEquip)

and the Output says, "Equipped is not a valid member of part" The Handle is this scripts parent, and The Handle's Parent is a Tool Instance. Thanks for the Help.

2 answers

Log in to vote
0
Answered by
Discern 1007 Moderation Voter
8 years ago

The Equipped event is fired on the Tool, not the Handle.

Also, the player's Humanoid is located in their character, not the actual player. You can access the Character using the Character property of the player.

Fixed Code:

-- Made by KenzaShadow --
local HealBall = script.Parent
function onEquip()
    local Player = game:GetService'Players'.LocalPlayer
    if (Player ~= nil) then
        Player.Character.Humanoid.MaxHealth = 200 --The character's humanoid, not the player's.
        wait(1)
        Player.Character.Humanoid.Health = Player.Humanoid.MaxHealth --The character's humanoid, not the player's.
    end
end
HealBall.Parent.Equipped:connect(onEquip) --The Handle's parent.

If I helped you out, be sure to accept my answer!

0
Thanks, but I want to know how to connect a function to a Equip event E.g, "script.Parent.Touched:connect(function(..." KenzaXI 166 — 8y
0
I answered your other question. Discern 1007 — 8y
Ad
Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

Equipped is not an event for Parts, because you don't equip Parts. It's an event for Tools. Therefore you just have to use the tool to access the event.

local HealBall = script.Parent.Parent

Answer this question