Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
camxd01 48
8 years ago

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

Log in to vote
0
Answered by 8 years ago

Well, coinage is pointless, as is spin.

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

0
I tried that before, it didn't work for me. camxd01 48 — 8y
Ad

Answer this question