Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I shorten this coroutine?(Function inside another function)

I have seen lots of posts that say that a function inside another function is unorganized. Since I am an asker, I want to be able to have cleaner scripts so that I can ask for help.

This code (snicker) functions

Cyvicz(Civics) is my currency.

Code:

--Made by CamScripted, cleaned by [YourNameHere]
local staph = 0
coin = script.Parent
a = 0


local h = Instance.new("Hint", workspace);
local m = Instance.new("Message", workspace);
 
local spin = coroutine.wrap(function()
    repeat
coin.Rotation = Vector3.new( 0, a, 0)
wait(.01)
a = a+3
until staph == 1
end)
local coinage = coroutine.wrap(function()
coin.Touched:connect(function()
	for _,Player in pairs(game.Players:GetPlayers()) do
	    if Player:FindFirstChild("leaderstats") then
	        Player.leaderstats.Cyvicz.Value = Player.leaderstats.Cyvicz.Value + 10
			coin.Parent = game.Lighting
			break
	    end
	end
	end)
end)

 
spin()
coinage()

1 answer

Well, coinage is pointless, as is spin.

Place the body of coinage above the body of spin and dont bother with the coroutines.

1 comment

0

I tried that before, it didn't work for me.

This discussion is preserved as it was. New answers, comments, and votes are closed.