#I want a Powerup like object to respawn 5 seconds after it has been picked up

1 messages · Page 1 of 1 (latest)

sharp finch
#

I cant get this to work, its been 3 days 😭

cunning mica
leaden wing
#

its just me? Bleeding my eyes, seeing not tab fixed REEEE

sharp finch
#

i dont know how that whould help, it can detect the tag, and the respawning works perfectly fine without the task. delay

#

but as soon as i try to somehow time that shit it all breaks

jagged gale
sharp finch
#

i solved respawning with transparency = 1 and cancollide off

jagged gale
#

so this solved now?

sharp finch
#

no

jagged gale
#

you want it to come back after 5 seconds?

sharp finch
#

yea

jagged gale
#

sure

sharp finch
#

i cant do it 😭

cunning mica
sharp finch
#

and why does it change anything?

cunning mica
sharp finch
#

okay

#

and combine that with a for_,

cunning mica
cunning mica
sharp finch
#

that does work

#

but i dont understand it :(

cunning mica
#

alr

#

what u are doing with that

#

is waiting until CollectionService, receive the signal of something that u have add the tag "Touched"

#

the Connect i guess u know what is doing

sharp finch
#

yes

#

okay thanks

jade plover
#

Except for the Collection service part 😂 ✌️ i assume its getting the signal of something being added

sharp finch
#

So is GetInstanceAddedSignal the way to go to solve all of theese actions?

cunning mica
# sharp finch yes

and when that happens, it gives you the direct object that was tagged, that's why you don't have to do the for _, ...

jade plover
#

and then waiting for 5 seconds, and making the part visible and can-collide and removing the touched tag

#

✌️

jagged gale
#
local food = workspace.FoodFolder.FoodObjecs
local cs = game:GetService("CollectionService")
local mult = 1
for _,food in food:GetChildren() do --pairs is so 2018
  food.Touched:Connect(function(part)
    local hum = part.Parent:FindFirstChild("Humanoid")
    local plr = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
    local touched = cs:HasTag(food, "Touched")
    if hum and plr and not touched then
      plr.leaderstats.JumpPower.Value += math.random(5,10) * mult
      cs:AddTag(food, "Touched")
      food.Transparency = 1
      food.CanCollide = false
      task.delay(5, function()
        food.Transparency = 0
        food.CanCollide = true
        cs:RemoveTag(food, "Touched") -- idk the method here, change it if it's wrong
      end)
    end
  end)
end
#

fully functional script

cunning mica
jagged gale
#

i never knew about collectionservice

sharp finch
jagged gale
#

if theres an error, feel free to change the variable names

jade plover
#

while im here using pairs and ipairs

#

aha

#

ahhha..

jagged gale
#

lol

jade plover
#

it's all about micro-performance kids!

#

aha

#

ahah

#

ok

sharp finch
#

so i should not use pairs?

jagged gale
#

yeah

jade plover
#

both works either ways

#

🤷‍♂️

winter talon
#

wait what do you use instead of pairs then