#replicated storage thing

1 messages · Page 1 of 1 (latest)

viscid wraith
#

i am making a game where i spawn blocks as one does and my script in the blocks don't work. i am cloning my blocks in replicated storage and making their parent the workspace

silk sparrow
#

could you send a picture of the script you are using to clone the blocks as well as the script the blocks have?

#

also you want to avoid making a new script per block, you can use a modular script since all of those clones will have the same code

viscid wraith
viscid wraith
#

this is the script inside the common block that spawns

silk sparrow
silk sparrow
# viscid wraith

move this local script to a script (white) or a modular script (purple) and put it in serverscriptservice

#

and im guessing the contents of that script are meant for everyone in the game, instead of doing player.localplayer do a for loop of every player in the server instead

viscid wraith
#

different for each person

silk sparrow
#

you are waiting until a player has 100 value right?

viscid wraith
#

yeah

silk sparrow
#

and that player that reaches 100 value will get their own stuff

viscid wraith
#

so there isn't infinite blocks spawned at once

silk sparrow
#

yea i ment that but i explained it poorly

#

imma make some code off the top of my memory

#

local players = game.players

for _,player in players:getchildren() do
function(player)
end

nocturne bayBOT
#

studio** You are now Level 3! **studio

viscid wraith
#

ah ok

silk sparrow
#

let me just open studio actually

#

ideally it would be a modular script

#

@viscid wraith does this make sense?

viscid wraith
#

not really

silk sparrow
# viscid wraith

could you copy paste the code into the chat and ill rewrite it

viscid wraith
#
local SpawnSpeed = 0.75

for _,player in players:GetChildren() do
    while task.wait(SpawnSpeed) do
        if game.Players.LocalPlayer:FindFirstChild("leaderstats").Spawned.Value == 100 then
            task.wait()
        else
            if math.random(6) == 6 then
                -- uncommon ig
                game.Players.LocalPlayer:FindFirstChild("leaderstats").Spawned.Value = game.Players.LocalPlayer:FindFirstChild("leaderstats").Spawned.Value + 1
                print("UnCommon")
                NewUnCommon = game.ReplicatedStorage.Blocks.All.UnCommon:Clone()
                NewUnCommon.Parent = game.Workspace
                NewUnCommon.Position = Vector3.new(2.5-math.random(98), 2.5, -48.5+math.random(98))
            else
                --common
                game.Players.LocalPlayer:FindFirstChild("leaderstats").Spawned.Value = game.Players.LocalPlayer:FindFirstChild("leaderstats").Spawned.Value + 1
                print("Common")
                NewCommon = game.ReplicatedStorage.Blocks.All.Common:Clone()
                NewCommon.Parent = game.Workspace
                NewCommon.Position = Vector3.new(2.5-math.random(98), 2.5, -48.5+math.random(98))
            end
        end
    end
end ```
silk sparrow
#

basically you are getting the list of players from the server

#

oh woops i forgot should probably make it a task.spawn

silk sparrow
#

i dont know if the red helps

#

but it starts off at 1 and then goes to 2

#

the difference between your currect script and the screenshot is that the game.players.localplayer is replaced with the player variable that was given from the loop in #1

#

because game.players.localplayer is only avaliable for client side scripts

viscid wraith
#

yeah

#

i forgot about that

silk sparrow
#

also since line 12 and 19 are the same thing

#

you can just move it outside the second if statement

viscid wraith
silk sparrow
#

player:FindFirstChild("leaderstats").Spawned.Value += 1

#

you can also do this instead of repeating the spawned.value thing again

#

+= basically means add whatever value is after the sign to the variable before the sign

viscid wraith
silk sparrow
#

you moved it from a local script to a server script right?

silk sparrow
#

perhaps it has something to do with the clone

#

i did notice there was no declaring of your variable NewUnCommon and NewCommon

#

did you make that global somewhere?

viscid wraith
silk sparrow
#

i wonder why urs isnt underlined then

viscid wraith
#

also the variable is a clone

silk sparrow
#

underneath the first else

#

put in local Clone

#

and then replace NewUnCommon and NewCommon with Clone (the variable name)

silk sparrow
#

yea

nocturne bayBOT
#

studio** You are now Level 4! **studio

viscid wraith
#

its not working still

silk sparrow
#

weird

#

ah wait

#

i think i know

#

classic

#

the script is loaded before the player actually joins

viscid wraith
#

of course

silk sparrow
#

is that script ment to be always running?

viscid wraith
#

yeah

silk sparrow
#

ok then instead of the for loop

#

test is the function name

#

or this

#

probably should do this one ^

viscid wraith
#

thanks it works now 🙏