Rotating Words System

,

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.

5 Likes

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.

3 Likes

That’s what I want to achieve, I want to get a single word.

1 Like

string.split() can help you with this

2 Likes

I will learn that, thank you!

chrss

2 Likes

It didn’t save me yet. Guess string.split() do not fix that.

1 Like

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()

2 Likes

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

1 Like

let me screenshot.

Moderation be like

invalid argument #1 to ‘char’ (number expected, got string)

use the newer method, fixed and optimised

1 Like

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

robloxapp-20230810-2049275.wmv (91.3 KB)