Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do detect if Text is printed?

Asked by 3 years ago

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

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. Dovydas1118 1495 — 3y
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 themaxogamer 58 — 3y
0
Just use a variable, or a debounce. Only use a print statement for troubleshooting. You can print the variable. Dovydas1118 1495 — 3y
0
hmm themaxogamer 58 — 3y
View all comments (2 more)
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. Fifkee 2017 — 3y
0
From this devForum, roblox recommends that you use module scripts instead of _G. https://devforum.roblox.com/t/g-or-modulescripts/173421/2 Dovydas1118 1495 — 3y

3 answers

Log in to vote
3
Answered by 3 years ago
Edited 3 years ago

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)
Ad
Log in to vote
2
Answered by 3 years ago

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)
0
(I think the scripts in this answer are pretty self-explanatory) IAmNotTheReal_MePipe 418 — 3y
Log in to vote
1
Answered by
Nckripted 580 Moderation Voter
3 years ago

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!

0
but how do i detect if its buffed since they are in 2 different scripts themaxogamer 58 — 3y
0
You would use either boolValue Instances that are checked in both scripts or by using remoteEvents (check my answer for the boolValue method) IAmNotTheReal_MePipe 418 — 3y

Answer this question