#userinputservice so funny :(
17 messages · Page 1 of 1 (latest)
you forgot to check if the variable is true
i'll edit your code a little and explain it
hold on
local UIS = game:GetService("UserInputService")
local eKeyPressed = false
UIS.InputBegan:Connect(function(input,gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.E then
if eKeyPressed == false then
eKeyPressed = true
else
eKeyPressed = false
end
end
end)
while wait() do
if eKeyPressed == true then
game.Workspace.part:Clone()
end
end
basically when you press checks if keypressed is true, if it is, sets to false
else (aka if keypressed is false) then keypressed true
the while loop just constantly checks for keypressed
Hell nah you used a true loop for that
local userInputService = game:GetService("UserInputService")
local eKeyPressed = false
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.E then
eKeyPressed = not eKeyPressed
end
end)
local function clonePart()
if eKeyPressed then
workspace.Part:Clone()
end
end
game:GetService("RunService").Stepped:Connect(clonePart)
@cyan sandal @viscid fox
I apologize if I disturbed you, I wanted you to look at the code so you can learn from it too.