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

Equip is not a valid member of Tool. Can anyone help?

Asked by 6 years ago

Roblox says Equip is not a valid member of tool, but it clearly is. This is the script that changes the BoolValue of Equipt:

01local tool = script.Parent
02 
03local function onEquip()
04    tool.Equip = true
05end
06 
07local function onUnequip()
08    tool.Equip = false
09end
10 
11local function onActivate()
12end
13 
14local function onDeactivate()
15end
16 
17tool.Equipped:Connect(onEquip)
18tool.Unequipped:Connect(onUnequip)
19tool.Activated:Connect(onActivate)
20tool.Deactivated:Connect(onDeactivate)

Here's Equip being a valid member of Tool: I would really appreciate if someone could help me with this.

0
By `tool.Equip = true`, you are just accessing the instance and setting it to true or false which makes no sense. You should set its value to true or false. There is a property of the instance called `Value` that is the one you should be modifying. So `tool.Equip.Value = true` valchip 789 — 6y

1 answer

Log in to vote
0
Answered by
BenSBk 781 Moderation Voter
6 years ago

To change the value of a BoolValue, or any other value object, you need to change the Value property. If you think about it, directly overriding the object itself would not work, and should not be expected to work.

To fix your script, simply append .Value to the object when changing or accessing its value:

1tool.Equip.Value = true
0
AKA what I said in the comments, also maybe his Equip BoolValue hasn't been loaded yet so he might want to use `:WaitForChild()`. valchip 789 — 6y
0
your comment wasn't there when i began answering mr vamik BenSBk 781 — 6y
0
^ I know I did not complain. valchip 789 — 6y
0
has happened to me before ¯\_(?)_/¯ valchip 789 — 6y
0
Thanks, I totally forgot about .Value :) vonotige 49 — 6y
Ad

Answer this question