#I want a Powerup like object to respawn 5 seconds after it has been picked up
1 messages · Page 1 of 1 (latest)
did you try what i told you?
its just me? Bleeding my eyes, seeing not tab fixed 
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
wheres the respawning part
real 🔥
i solved respawning with transparency = 1 and cancollide off
so this solved now?
no
you want it to come back after 5 seconds?
yea
sure
i cant do it 😭
in the other post that u have made, i told u to use CollectionService:GetInstanceAddedSignal
yes, i have no clue how that works
and why does it change anything?
cuz, u are using while true do, and that maybe cause some weird things
no
delete all the while
and try
CollectionService:GetInstanceAddedSignal("Touched"):Connect(function(foodItem)
task.wait(5)
foodItem.Transparency = 0
foodItem.CanCollide = true
CollectionService:RemoveTag(foodItem, "Touched")
end)
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
it's quite simple really
Except for the Collection service part 😂 ✌️ i assume its getting the signal of something being added
So is GetInstanceAddedSignal the way to go to solve all of theese actions?
and when that happens, it gives you the direct object that was tagged, that's why you don't have to do the for _, ...
and then waiting for 5 seconds, and making the part visible and can-collide and removing the touched tag
✌️
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
there is many i guess, literally yesterday I learned about the collection service
i never knew about collectionservice
sick, now i dont need a second script
if theres an error, feel free to change the variable names
pairs is so 2018 💔
while im here using pairs and ipairs
aha
ahhha..

lol
so i should not use pairs?
yeah
wait what do you use instead of pairs then