Hey, how would I make an experience pick-up system like in the game Vampire Survivors?
Example (blue gems)
You could spawn those blue jems every once in a while, and when a player gets close to it you could tween it to them and then add points to their experience. Now how you can do this, I’ll give you a general idea
- make a loop to spawn them every,say, 5 seconds
- Have a hitbox around them that will be the activator of the tween when a player touches it
- Tween it to them (would be good to tween to hmr)
- Add their points to their experiences once the tween completes (if it’s leaderstats then yk what to do)
Here’s the scripted example (This script is in SSS)
local TS = game:GetService('TweenService')
for i, gem in pairs(workspace.SpawnedGems:GetChildren()) do
gem.Hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
local char = hit.Parent
TS:Create(gem,TweenInfo.new(3,Enum.EasingStyle.Sine),{Position = char.HumanoidRootPart.Positiom}):Play()
wait(3) -- Here I will wait the tween time. You can do tween.Completed:Wait() instead
gem:Destroy()
player.leaderstats.Experience.Value += gem:GetAttribute('Experience')
end
end)
end
1 Like