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

Will this work?

Sadly, I can't test this in Studio's Play Solo, since we can not chat there.

What this code is meant to do is, if someone wants to go BRB/AFK, then they chat a certain phrase that should continuously make them jump until they say "I'm back" to stop the jumping and return them to normal.

BRBMode = false
game.Players.LocalPlayer.Chatted:connect(function(msg)
	if msg == "I'll BRB" then
		BRBMode = true
	elseif msg == "I'm Back" then
		BRBMode = false
	end
end)

while BRBMode == true do --Did I do this correctly?
	game.Players.LocalPlayer.Character.Humanoid.Jump = true
	wait()
end

3 comments

0

Should work. Why don't you just test it in online mode, to see if it works for yourself?

0

Humanoid.J?

0

@Perci1, Thanks for your prediction. Sadly, all my spaces have been accumulated and there won't be enough space to publish the Alpha version on ROBLOX.

2 answers

✓ Accepted answer
while BRBMode == true then

I'm not sure if that will work considering that the true is used in other while scripts. How about you make it a number instead of a bool?

BRBMode = 1 -- Number for false
game.Players.LocalPlayer.Chatted:connect(function(msg)
if msg == "I'll BRB" then
BRBMode = 2 -- Number for true
elseif msg == "I'm Back" then
BRBMode = 1
end
end)

while BRBMode == 2 do --Did I do this correctly?
game.Players.LocalPlayer.Character.Humanoid.Jump = true
wait()
end

That should work better.

1 comment

0

Thanks!

This might be more efficient

--when going brb
Instance.new("ForceField" game.Players.LocalPlayer.Character) -- Creates a ForceField for the player, Instance.new allies you to create items.
--Coming back from AFK
for I,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do --Fetches all items in the player
if v:IsA("ForceField") then --sees if any object is the ForceField we made
v:Destroy()
end
end

2 comments

0

Would this avoid disconnection from servers?

0

Yes, since when a player leaves the game it would delete the player including the local script.

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