✓ Accepted answer
Ok, lets try it
I already saw a lot of people missing the "equipped" function of the tools. So lets apply it here so you can know how to fix this problem again in the future!
First Step : We need to know how and where we can use the equipped() function. So lets take an expample I made.
local tool = game:GetService("ReplicatedStorage").Tool
local messageP = "We are fine!"
local function equipped()
print(messageP)
end
script.Parent.Equipped:Connect(equipped)
And that's how we get the "Equipped" function. We can get even a character or a Humanoid. But now we will use this even to make it like you want
Second Step : Enjoy coding! You always have to enjoy what are you doing! Play some music while you script or even play something before to be relaxed!
Lets get into the code!
local function equipped()
if script.Parent.Equipped then
workspace:FindFirstChild("Door").CanCollide = false
wait()
end
end
local function equippedFinished()
if not script.Parent.Equipped then
game:GetService("ReplicatedStorage").Status.Value = "Its to dark here! You need a lintern! Or maybe a flashlight"
wait()
game:GetService("ReplicatedStorage").Status.Value = ""
end
end
script.Parent.Equipped:Connect(equipped)
script.Parent.Unequipped:Connect(equippedFinished)
local warnMessage = "The script is incorrect!"
pcall(warnMessage)
And that's all! Now you can enjoy your pieces of code! If this helps you let me know.
I hope my answer already solve your question. If is that the case, please accept my answer. That will help me a lot!
Keep scripting!
1 comment
Please provide more information