local text = "Play"
local spacedText = ""
for i = 1, #text do
spacedText = spacedText .. text:sub(i, i) .. " "
end
script.Parent.Text = spacedText
Try this, I would recommend putting it inside a function if you want the code to be reusable and more compact. Like this:
function onMouseEvent(eventType)
local text = "Play"
if eventType == "MouseEnter" then
text = "P l a y"
end
local spacedText = ""
for i = 1, #text do
spacedText = spacedText .. text:sub(i, i) .. " "
end
script.Parent.Text = spacedText
end
script.Parent.MouseEnter:Connect(function()
onMouseEvent("MouseEnter")
end)
script.Parent.MouseLeave:Connect(function()
onMouseEvent("MouseLeave")
end)
You can also have the "Play" and "P l a y" be a function parameter. Although it’s really optional and up to you.