Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

2 comments

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?

0

yes,It saids so,pls approve if this works

This discussion is preserved as it was. New answers, comments, and votes are closed.