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

How do detect if Text is printed?

im making a buff move on the sword when you press F it prints

print("Buffed")

how can i detect that in the script?

im triyng to make it like

if printed ("buffed") then

damage increases

6 comments

0

There is no need for that. You don't need an if statement for a print statement. You can use a variable instead, if you'd like. Print() should be used for troubleshooting purposes only.

0

i just want to detect when text is printed so i can use it like if text is printed then healthloss = 40 when its normaly like 20

0

Just use a variable, or a debounce. Only use a print statement for troubleshooting. You can print the variable.

0

hmm

0

_G seems like the best case for this one. Don't use _G unless you're 4000% sure that the variable you're looking for is initialized at every single time you need it, but in this case you don't need to know if it's initialized or not.

0

From this devForum, roblox recommends that you use module scripts instead of _G. https://devforum.roblox.com/t/g-or-modulescripts/173421/2

3 answers

✓ Accepted answer

You could use the LogService.. it allows you to listen for when text is printed in the output.. Although I recommend only using it for logging purposes, it should work for your purpose..

local LogService = game:GetService("LogService");

LogService.MessageOut:Connect(function(message, messageType)
	if not (messageType ==  enum.MessageType.MessageOutput) then return end
	if(message == "buffed" then
		--the code to increase damage goes here
	end
end)

Set "buffed" script:

local buffed = game.Workspace:WaitForChild("Buffed?") --Name and location of your boolValue

buffed.Value = true

Read "buffed" script:

local buffed = game.Workspace:WaitForChild("Buffed?")

buffed.Changed:Connect(function()
     if buffed.Value == true then
          --Code
     end
end)

1 comment

0

(I think the scripts in this answer are pretty self-explanatory)

As far as I am concerned, that is not possible. Just simply use a variable like this:

local buffed = true

if buffed then
	--Increase damage
else
	--Do nothing
end

In other words, instead of doing a print, change the variable.

Hope this helped!

2 comments

0

but how do i detect if its buffed since they are in 2 different scripts

0

You would use either boolValue Instances that are checked in both scripts or by using remoteEvents (check my answer for the boolValue method)

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