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

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

Asked by 3 years ago

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

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

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.

Ad
Log in to vote
0
Answered by 3 years ago

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

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

Answer this question