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
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
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)
(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!
but how do i detect if its buffed since they are in 2 different scripts
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.
6 comments
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.
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
Just use a variable, or a debounce. Only use a print statement for troubleshooting. You can print the variable.
hmm
_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.
From this devForum, roblox recommends that you use module scripts instead of _G. https://devforum.roblox.com/t/g-or-modulescripts/173421/2