Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

Will this spawn multiple models in one space?

Asked by
Fifkee 2017 Administrator Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

Hey guys, I have a question.

local function setupPlayerData(player)
    local data = DataStore1:GetAsync(player.UserId)
    if not data then
        data = {Items = {}, Money = 0, Experience = 0}
        DataStore1:SetAsync(player.UserId, sessionData[player])
    end
    sessionData[player] = data
end

game.Players.PlayerAdded:connect(setupPlayerData)

local function savePlayerData(player, playerItems)
    for i, v in ipairs(workspace[player.Name].itemHolder) do
        sessionData[player].Items[v.Name] = {
            CFrameValues = {v:GetPrimaryPartCFrame().X, v:GetPrimaryPartCFrame().Y, v:GetPrimaryPartCFrame().Z, v:GetPrimaryPartCFrame():toEulerAnglesXYZ()}
        }
    end
    DataStore1:SetAsync(player.UserId, sessionData[player])
end

I have a three by three grid that saves every sixty seconds (or, one minute.) Once the game saves twice with a part unmoved, on the next game join, will there be three parts in the same location?

If so, how would I prevent that?

Baseplate loading code:

function loadPlayerData(player)
    for i, v in ipairs(sessionData[player][Items]) do
        local Base = workspace:WaitForChild('Baseplates'):WaitForChild(player.Name)
        local Item = game:GetService'ReplicatedStorage':WaitForChild('gameItems'):FindFirstChild(sessionData[player].Items[v.Name]):Clone()
        Item.Parent = Base:WaitForChild("itemHolder")
        Item.CFrame = CFrame.new(sessionData[player].Items[v.Name].CFrameValues)
    end
end
game.Players.PlayerAdded:connect(loadPlayerData)

There might be errors I'm not aware of. I'll fix these errors while someone comes up with an answer.

0
I do not understand your question. ILikeTofuuJoe 1 — 2y
0
Alright. In a model (which there is FOUR of), there are two items inside. itemHolder, and the actual baseplate. Everytime someone places an object down, nothing happens. Every autosave, the game gets EVERYTHING in the user's baseplate, and saves it. If someone leaves (because if someone leaves, it autosaves also), would it spawn multiple parts in the same area on join? Fifkee 2017 — 2y
0
There would probably not be any diffrences though, the models are the same and they overlap. ILikeTofuuJoe 1 — 2y
0
Sell crates are taken into consideration, that's the problem. If two sell crates are in one position, then double the money from one sell crate. That would be kind of overpowered in the long run. Fifkee 2017 — 2y
0
Agree. They could get a lot of money by keep quitting and joining the game. ILikeTofuuJoe 1 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Yes. It will. EDIT: Add this

game.Players.LocalPlayer.modelSpawned = true

Add a part of the script that would detect if modelSpawed is true. If it is then probably do a return end) . Also set modelSpawned to false when the player first joined.

0
then, how would I prevent it? Fifkee 2017 — 2y
0
@ILikeTofuuJoe This is an irrelevant answer. If you're going to post an answer, provide how it's done and explain. SilverCreeper58 23 — 2y
0
So it didn't say anything about not letting the player spawn more models. ILikeTofuuJoe 1 — 2y
0
Don't try to get free reputation points, I literally commented "how would I prevent it?" aeiou Fifkee 2017 — 2y
View all comments (2 more)
0
By making a thing that would change a value to true. And if the value is true, make it so that the players can't spawn any more models. ILikeTofuuJoe 1 — 2y
0
I am certainly not getting free reputation. I have 0 reputation ok. A lot of my answers have errors in them. I just hope I don't get negative reputation. That's it. ILikeTofuuJoe 1 — 2y
Ad

Answer this question