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

Why isn't this KeyDown script working?

Asked by 10 years ago

My script resets a player when a tool is selected and "r" is pressed. The script is a LocalScript and is in a Tool.

function onKeyDown(key) 
    key:lower() 
    if key == "r" then 
        game.Players.LocalPlayer.Character.Humanoid.Health = 0
    end
end 


function onSelected(mouse) 
    mouse.KeyDown:connect(onKeyDown) 
end 

script.Parent.Selected:connect(onSelected)

But it doesn't do anything. Can anyone help me out?

0
Try and use the 'Equipped' event. Redbullusa 1580 — 10y
0
Equipped works. Thanks! whyOmustOitObeOme 7 — 10y

1 answer

Log in to vote
0
Answered by
Mr_Octree 101
10 years ago

I've tested this in studio, and it seems to work just fine. Perhaps you made it a Script instead of a LocalScript?

0
No, I'm certain it's a LocalScript. whyOmustOitObeOme 7 — 10y
0
Hm, if it's in the correct place(Being the child of the Hopperbin) then I am not sure. Are there any error messages in the output? Mr_Octree 101 — 10y
0
No whyOmustOitObeOme 7 — 10y
0
Could you screenshot the Explorer and the Script editor for me? Mr_Octree 101 — 10y
Ad

Answer this question