I made this script to change a value in the player’s head when the user clicks the mouse. The remote event is fired when they do.
It was working with the tool unequipped so I thought I would add some code to make it only work when the tool is equipped. The only problem is that the equipped value is always false. I’m very confused!
It is late so I might be missing something obvious
local CD = false
local animId = 6783774822
local equipped = false
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
print(equipped)
if CD == false and plr.Character.Head:FindFirstChild("Damage") then
if equipped == true then
CD = true
plr.Character.Head.Damage.Value = true
print("Bite")
wait(1.5)
CD = false
plr.Character.Head.Damage.Value = false
end
end
end)
script.Parent.Equipped:Connect(function()
equipped = true
end)
script.Parent.Unequipped:Connect(function()
equipped = false
end)
Tool.Equipped and Tool.Unequipped are events, not properties.
What you could do is try and define the tool as its own variable, like local Tool = script.Parent.
@itsXtimes They are not member of tool, but rather an event. Please make a research before sending solutions.
@jsnotlout1 Based on the content of the script, I assume this is a server script. It is suggested to use a local script in a tool instead of a server script to reduce the load in the server.
An event is an object itself. It does not pertain to conditionals (true/false), numbers and strings. It is its own object which a unique function.
This is not how an event works. An event is an object that can be connected and be fired when conditions are met. Equipped fires when the character equips a tool has that Equipped event.
@FunnelDeveloper@itsXtimes We are correcting you guys so that confusion like this won’t happen in another post.
Well, I’ll just stop correcting now. It should be enough to clear the confusion.
@OP, if the equipped variable is still false, it means that the event didn’t fire. In your script, the only condition that the variable will change is when an event fired. It would really be helpful if you could send what type of script it is, where you put the tool, and much more.