I am working on a GUI and I need to know a way to rotate a single word on a text label, any thoughts? Thank you in advance! Sorry to the ammount of lines I typed, I just can not think any other things to tell for.
You could use TweenService and tween the TextLabelâs Rotation property. If you mean rotating just one word of a TextLabel containing multiple, I think your best bet would be seperating your TextLabel into multiple parts for each word and tweening each label that way, as I donât think thereâs a way to do that.
Thatâs what I want to achieve, I want to get a single word.
string.split() can help you with this
I will learn that, thank you!
chrss
It didnât save me yet. Guess string.split() do not fix that.
try this:
local textlabel = pathtotextlabel --change
function duplicateWord(word, text, label)
if text:find(word) then
local starti, endi = text:find(word)
local substring = text:sub(starti, endi)
local substringTwo = text:char(starti - 1)
local length = substring:len()
local lengthTwo = substringTwo:len()
local replacement = ""
local replacementTwo = ""
for i = 1, length do
replacement = replacement.." "
end
for i = 1, lengthTwo do
replacementTwo = replacementTwo.." "
end
label.Text = text:gsub(text, substring, replacement)
local clonedText = label:Clone()
clonedText.Text = replacementTwo..substring
return clonedText
else
return false
end
end
function rotate(label, degrees, speedmultiplier)
if not label then return end
local amount
if degrees and degrees ~= 0 then amount = degrees else amount = 360 end
local speed
if speedmultiplier and speedmultiplier <= 0 then speed = speedmultiplier else speed = 1 end
for i = 1, amount do
label.Rotation += 1
task.wait(0.03 * speed)
end
end
local label = duplicateWord("wow", "wow! this is... AMAZING!!!", textlabel)
coroutine.wrap(rotate)(label) --degrees and speedmultiplier default to 360 and 1, respectively
do note that this script duplicates the original textlabel so that it does not get affected by rotate()
the better method: the one that doesnât duplicate:
- In explorer, duplicate (yes, I know itâs duplicating but itâs better to duplicate manually than automatically) the textlabel, fit it so that it can be rotated easily
Example: The duplicated textlabel is in bold
This is an example!
- Inside, add a local script:
local rotate = coroutine.wrap(function(degrees)
for i = 1, degrees do
script.Parent.Rotation += 1
task.wait()
end
end)
rotate(360) --360 is a full turn
let me try that! How can I put that so anything is ok?
What do you mean by that?
[remove30charrule]
Where do I put that I mean.
aaaaa
just put this function anywhere inside a localscript that handles the labels,
modification:
local rotate = coroutine.wrap(function(degrees, label)
for i = 1, degrees do
label.Rotation += 1
task.wait()
end
end)
rotate(360, textlabel) --360 is a full turn, and textlabel is the label being rotated
make sure that you do not have a variable named label, else if you need it, just replace label inside the function to something you donât have
Example:
local label = lalalalalalalala
local rotate = coroutine.wrap(function(degrees, abcdefg)
for i = 1, degrees do
abcdefg.Rotation += 1
task.wait()
end
end)
rotate(360, textlabel) --360 is a full turn, and textlabel is the label being rotated)
But is this getting the WORD or the LABEL itself?
the TextLabel is the duplicated textlabel that contains the word
let me screenshot.
Moderation be like
invalid argument #1 to âcharâ (number expected, got string)
use the newer method, fixed and optimised
It workss, but! Remember I need Just one Word. Let me screenshot.
The label is the âSansâ on âUndertale! Sansâ, I am using Rich text.
video of rotation?
remove30charrule