Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

i tried this script out and when i clicked f nothing happened what am i doing wrong?

local repatore = game:WaitForChild("ReplicatedStorage")
local Remote = repatore:WaitForChild("iceStart")


Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()

cool = true

Mouse.KeyDown:connect(function(key)
key = key:lower()
if key == "f" then
	 if cool == true then return end
	 cool = false
	
	print("Worked")
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	wait(5)
end
end)

5 comments

0

I put the code in a code block and fixed the indentation.

0

Why did you put it back it how it was prior?

0

im new to this i did not know how to use the lua edit thingy

0

wdym by you put the code in a code block which code and how to put code's in code block's

0

It's cool; I recommend checking this out for future reference. https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site

1 answer

KeyDown is deprecated, you will need to use the UIS (UserInputService) instead.

local repatore = game:WaitForChild("ReplicatedStorage")
local Remote = repatore:WaitForChild("iceStart")

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local cool = true

game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.F then
		if cool == false then return end
		cool = false
	    
		print("Worked")
		
		wait(5)
		cool = true
	end
end)

Also, assuming "cool" is a debounce, you will want it to function as above in the script (reversing the bool positions), since otherwise, having defined "cool" as true to begin with, the script will never run past the "return end" line.

This discussion is preserved as it was. New answers, comments, and votes are closed.