Random Text spawn

local function getPowerTween()
			local textClone = player.PlayerGui.UnderGui.plusPower:Clone()
			textClone.Name = "TextClone"
			textClone.Parent = player.PlayerGui.UnderGui
			textClone.Text = "💪+".. plusPower.Value
			
			local Info = TweenInfo.new(0.6)
			local Tween = tween:Create(textClone, Info, {TextTransparency=0})
			local Tween2 = tween:Create(textClone.UIStroke, Info, {Transparency=0})
			local Tween3 = tween:Create(textClone, Info, {Position = player.PlayerGui.UnderGui.Strength.Position})
			
			Tween:Play()
			Tween2:Play()
			textClone.Position = UDim2.new(math.random(0.1, 0.6), 0, math.random(0.15, 0.75), 0)
			
			wait(0.4)
			
			Tween3:Play()
			
			wait(0.2)
			
			textClone.Visible = false
		end
		
		getPowerTween()

So here is a part of my script in which I want the text to spawn in a random (almost) part of the screen, and fly to a certain point. But for some reason, my text appears only in one position why?

math.random doesnt take in float parameters (decimals) so pass them in as integers and then divide by a multiple of 10 to reduce it to a decimal value.

will be

textClone.Position = UDim2.new(math.random(1, 6) / 10, 0, math.random(15, 75) / 100, 0)

Alternatively you can use the NextInteger() function of Random

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.