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

How can I make this only print once?

local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char.Humanoid

hum.Running:connect(function(speed)
	if speed > 0 then
	print(" I'm walking ")
	else
	print("I stopped walking")
	end
end)

How can I make this print once? So when he starts walking it only prints it once? and not repeatly and infinitely? And when he stops he only prints the "I stopped walking" once?

1 comment

0

Does the speed change if you stop walking the walk speed of the humanoid... I don't think that the walk speed of the humanoid changes... What is the argument of speed?

3 answers

✓ Accepted answer

This is simple I included debouncers and alot more aswell.

local plr = game.Players.LocalPlayer

local char = plr.Character

local hum = char.Humanoid

local prin = true
local deb = true

hum.Running:connect(function(speed)
    if speed > 0 then
    if prin and deb then
	deb, prin = false
    print("Walken")

wait(0.2)
deb = true
end
elseif not prin and deb then
	deb, prin = false, true
print("Stopped")
wait(0.2)
deb = true

    end
end)

2 comments

0

Why do you make a double debounce?

0

one is so they have to wait a specific time before being able to do it again. and another is to show that we have allready ran and we are waiting for the person not to be running. e.e.

I think it isn't possible. Maybe use debounce?

2 comments

0

You're right but the way he would have to use the debounce would be a little different in order to allow the script to detect when the speed is also 0. Maybe two denounces...

1

Yeah, maybe. I am really bad in lua actually. My lua is really basic.

local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char.Humanoid
local print = false


hum.Running:connect(function(speed)
    if speed > 0 then
    if not print then
    print = true
    print(" I'm walking ")
    else
    print("I stopped walking")
    print= false
    end
end)

This is a situation where debounce comes in hand. It's intended for situations like this where the output is flooded with spam.

For more information, refer here.

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