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

11 comments
you're connecting a keyboard event to the mouse, that's the problem
But if I want to make a script that when I have my mouse on a part and then press "F" it gets destoyed. How do I do that?
embed a UserInputService or ContextActionService function inside of the ClickDetector function
KeyDown in general is deprecated
you gotta use UserInputService
That's why it isn't working
Okay thank you, I'll try that.
Np, did my answer help?
I'm working on it, but I think it will work.
Use :Connect not :connect
ok