I need help with this script
This is the error "Workspace.Crystal.Script:5: attempt to index a nil value"
script.Parent.ClickDetector.MouseHoverEnter:Connect(function(player) db = true player:GetMouse().KeyDown:connect(function(k) k = k:lower() if k == "f" then if db == true then script.Parent:Destroy() end end end) end)
What is wrong here?
It supposed to when you hover your mouse over the part and then press "F" it should get destroyed.
Thanks
KeyDown
is deprecated, use the UserInputService
.
You'll be using it like this.
script.Parent.ClickDetector.MouseHoverEnter:Connect(function(player) db = true game:GetService("UserInputService").InputBegan:Connect(function(k) if k.KeyCode == Enum.KeyCode.F then if db == true script.Parent:Destroy() end end end) end)