Hello,
So I am making a game, in which when you click on the item on the floor, it will disappear between 2-4 minutes. However, when I tested this out, the item was set to invisible for lets say 132 seconds, but once it reappeared, when I pressed it again, it disappeared for 132 seconds.
The question I want to ask is if you can actually make it invisible for a different amount of time each time the item is clicked. So I don't want it to disappear for 132 seconds every time, because for the more "common" items, people can just camp them. I want it to have a random rate but I'm not sure how.
--Variable Definition local cc = script.Parent local candycane = game:GetService("ReplicatedStorage").candycane local cd = cc.ClickDetector local randomnumber = math.random(120,240) --Main bit cd.MouseClick:Connect(function(player) local bp = player.Backpack if not bp:FindFirstChild('candycane') then candycane:Clone().Parent = bp print(randomnumber) -- this is so I can see how long it's disappeared for. wait(1) cc.Handle.Transparency = 1 wait(randomnumber) cc.Handle.Transparency = 0 else print "already in backpack bro ,what ya doing fam, you stupid boy" end end)
So what I did was i defined math.random(m,n)
at the start, then referred to it after I set the handle Transparency = 0
So every time I start running the script again, the time (for example) is 165, and the item is invisible for 165 seconds (after being clicked on), then it is visible again. But when i click on it again, the time it disappears for is 165 again, which I don't want to occur. I want these items to be Legendary, so the spawn rates are random and I will add in a script which will move the object.
However this only happens for one item. So the candy cane I have in this script spawns at 182 seconds (using math.random) but when it reappears, it disappears for 182 seconds, but i want it to disappear for a different number
So can someone help me? Every time I click the item, the number from math.random i get is like (another example) 182, then I want it to generate another random number, and not use 182 again.
Thanks, Tony V
Put math.randomseed(tick())
at the top of your script
randomseed()
has 1 argument, which is the given seed. In this case, we input tick()
, which is the amount of time that has passed on the client's computer since the UNIX epoch (January 1st, 1970) The key here is that time is never the same in any case, so this is a truly random seed.