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

How do you make a star collecting system for a platformer game?

I cannot find any tutorials on how to make a star collecting system like adventure forward and roblox quest. Can anyone help me.

2 answers

You would need to make a .Touched event. If you are putting the script inside the star, It would be like.

script.Parent.Touched:Connect(function (hit)
script.Parent:Destroy
--Your script to award the player
end)

Whenever you touch the star it will get destroyed, then you can award the player however you'd like, I don't know how you are gonna so I did not include it, Nor I can spoon feed. You would need to have a tween CFrame animation if you wanna make it go up and down and swirl in the air.

Add a script inside ServerScriptService then put the code:

for _, Star in pairs(game:GetDescendants()) do -- Checks for every object inside the workspace
	if Star:IsA("Part") then -- checks if its a part (change this if your star is Union to "UnionOperation")
		Star.Touched:Connect(function(hit) -- Checks if something hits the object
			if Star.Name == "Star" then -- checks the name of the object
				if hit.Parent:FindFirstChild("Humanoid") then -- finds humanoid inside the touched.Parent
					
					local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- variable for player
					local leaderboard = player:WaitForChild("leaderboard") -- variable for leaderboared
					local star = leaderboard:WaitForChild("Star") -- variable for star (change this if ur Star leaderstat is different)
					
					star.Value = star.Value + 1 -- adds value (Change 1 to everything you want)
					game.Debris:AddItem(Star, 0) -- destroy the star
					
				end
			end
		end)
	end
end

the explanations are inside the code. If it works tell me even if it doesn't so I can help you

10 comments

0

This is a single script so you don't need to put a script in every star in the game.

0

Hi! If you use the IsA function a lot for finding parts, meshparts, unions, wedges, etc, I'd recommend using IsA("BasePart") instead of "Part". It works for any type of part, including wedges, etc.

0

Thanks for the script, but I somehow still can't get it to work.

0

Whats ur star classname

0

As in what its supposed to be? It's supposed to be a battery

0

huh? Select your part then open properties look for classname

0

It's a union so I put unionoperation on the script but it still doesn't work

0

Is the Star name is exactly "Star"? or what your Star stat name?

0

yea it is

0

uhh idk now. Is there any error?

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