of     1   

BIueguy195
#139344582Saturday, July 05, 2014 8:16 PM GMT

fish = {"You caught a shark!", "You caught a pufferfish!", "You caught a clownfish!", "You caught a Go Fish!", "You caught a mackerel!", "You caught a JellyFish!"} local tool = script.Parent local user tool.Equipped:connect(function(mouse) user = tool.Parent mouse.Button1Down:connect(function() w = 1 if w == 1 then local ray = Ray.new(tool.ring.CFrame.p, (mouse.Hit.p - tool.ring.CFrame.p).unit*300) local hit, position = game.Workspace:FindPartOnRay(ray, user) local distance = (position - tool.ring.CFrame.p).magnitude local rayPart = Instance.new("Part", user) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Really Black") rayPart.Transparency = 0 rayPart.Anchored = true rayPart.CanCollide = true rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(position, tool.ring.CFrame.p) * CFrame.new(0, 0, -distance/2) m = Instance.new("Message") wait(3) user.RayPart:Destroy() m.Parent = game.Workspace m.Text = fish[math.random(1, #fish)] wait(2) m:Destroy() w = 0 end end) end) So let's say I want Shark to be the least common. How would I do that?
BIueguy195
#139344741Saturday, July 05, 2014 8:18 PM GMT

b1
BIueguy195
#139345693Saturday, July 05, 2014 8:28 PM GMT

Help?
Trioxide
#139345900Saturday, July 05, 2014 8:30 PM GMT

Create a random number and lets say 100 is max: local number = math.random(1,100) Then give each fish a number. SharkChance = 10 Fish1 = 30 Fish2 = 50 Fish3 = 100 Then check if number is smaller than SharkChance, if it is, you got a shark, if not, you check the next fish. You could do this more effiently.
BIueguy195
#139346492Saturday, July 05, 2014 8:37 PM GMT

So I'm going to have to get rid of the table?
BIueguy195
#139347531Saturday, July 05, 2014 8:48 PM GMT

bemp
purplescheer9
#139347693Saturday, July 05, 2014 8:50 PM GMT

You can do math.random() in tables by doing math.random(1, #TableNameHere) ~I like trees
robokittydestroyer
#139348231Saturday, July 05, 2014 8:55 PM GMT

@purple, that's what he's already doing. You could make a table with multiple copies of each value. For example, you would put 5 copies of "Shark", 20 copies of "Fish1", 25 copies of "Fish2", and 50 copies of "Fish3". It doesn't have to add up to 100 like I've done, but it would be easier to calcuate percentages that way.

    of     1