I cannot find any tutorials on how to make a star collecting system like adventure forward and roblox quest. Can anyone help me.
COMMUNITY QUESTION
How do you make a star collecting system for a platformer game?
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

10 comments
This is a single script so you don't need to put a script in every star in the game.
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.
Thanks for the script, but I somehow still can't get it to work.
Whats ur star classname
As in what its supposed to be? It's supposed to be a battery
huh? Select your part then open properties look for classname
It's a union so I put unionoperation on the script but it still doesn't work
Is the Star name is exactly "Star"? or what your Star stat name?
yea it is
uhh idk now. Is there any error?