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

How to make Coins Spawn anywhere in world like a simulator?

Asked by 4 years ago

i'm trying to make a simulator but the coin is in one place and not randomly spawning or cloning itself. give me examples of scripts to use

0
ScriptingHelpers is not a request site. Please make your own scripts, and if they give an error, or if you're not sure how to do them, ask a question. For a similar thing, check these videos out: https://www.youtube.com/watch?v=RoENRFy4ofA&list=PLuEQ5BB-Z1PJ4JIDXpttxuvCzJMeIqzMi&index=16, https://www.youtube.com/watch?v=rsTN0DppMaA&list=PLuEQ5BB-Z1PJ4JIDXpttxuvCzJMeIqzMi&index=17 Cyroxite 46 — 4y
0
Bro, you need to chill Pokemaster BradNewTypical 232 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
local Coin = game.ServerStorage.Coin --Location of the coin, recommend it be a part, mesh part, or part with mesh
local Delay = 10 --Delay until spawns another
local Y  = 4 --The Y axis you want the coins to spawn in

local Base = game.Workspace.Base --The base/the area you want it to spawn in

local function GetPos()
    local X_Size = Base.Size.X
    local Z_Size = Base.Size.Z

    local Max_X_Pos = Base.Position.X + X_Size
    local Max_Z_Pos = Base.Position.Z + Z_Size

    local Min_X_Pos = Base.Position.X - X_Size
    local Min_Z_Pos = Base.Position.Z - Z_Size

    return math.random(Min_X_Pos, Max_X_Pos), math.random(Min_Z_Pos, Max_Z_Pos)
end

while true do
    local NewCoin = Coin:Clone()
    NewCoin.Parent = game.Workspace

    local X,Z = GetPos() --Get workable position
    NewCoin.Position = Vector3.new(X, Y, Z) --If this doesn't work, try CFrame

    wait(Delay)
end

I haven't tested it, just came up with it. Hopefully it works!

0
thanks ill try it DarrenTheReaper 0 — 4y
Ad
Log in to vote
0
Answered by
hokyboy 270 Moderation Voter
4 years ago

First try to script it you're self you dont learn if you just copy scripts Ur gonna need The Clone() function and a loop

best of luck

Answer this question