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

how do I make coins appear randomly on the my map? + Game saving questions

Asked by
lytew 99
4 years ago

Hello! So, I'm making a coin system in my game (a game that simulates a race). I created a part of a coin and added a counter. But now I would like to make these coins (part) appear randomly through the race and keep moving (example: left, right, up and down), and I would also like to know how I save this information so that the player does not lose his money when he leaves the game

accountant script:

game.Players.PlayerAdded:Connect(function(plr)

    local paste = Instance.new("Folder",plr)
    paste.Name = 'leaderstats'
    local money = Instance.new("IntValue",paste)
    money.Name = 'money'
end)

coins(part) script:

local debounce = false
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') then
        if debounce == false then
            debounce = true
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.leaderstats.money.Value = player.leaderstats.money.Value + 1
            script.Parent:Destroy()
        end
    end
end)

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Put this is ServerScriptService and make it a Script

while true do
    local pos1 = math.random(-512,512) --Make the number smaller so that It can fit in your Baseplate(X and Z axis)
    local pos2 = math.random(-512,512) --Make the number smaller so that It can fit in your Baseplate(X and Z axis)

    local part = game.Workspace.YourPart --Change the name to your part
    part.Position = Vector3.new(pos1, 21, pos2) --Change 21 to make it lower or higher(Y axis)
end

Tell me if there is any problems, If it works please Approve it.

0
interesting, now all we need to do is move the coin (from left to right and back and forth) alias, to save the information, do I just have to add this to a script on the serverScriptServer? lytew 99 — 4y
0
yes,It saids so,pls approve if this works EnchMusic 26 — 4y
Ad

Answer this question