Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there something i can use that will give me more than 2 random arguments?

Hi. First off, I'm just messing around with the code of someone else's work to help get a better understanding of how it works so I can make my own version without stealing all there code. I would like to make it so that the blood particles that spawn, spawn randomly on different limbs. It normally just spawns on the torso which looks weird.

I tried to use math.random to make a random value, but I want more than 2 arguments, is there some function that can do that? I'm not aware of it and I'm pretty new to coding.

2 comments

0

I am somewhat confused as to what you mean.. Do you want to get multiple values from math.random? If so, I'd do a for loop to get multiple math.random values.

0

they want to chose a random part of the body and put blood particles on that part

1 answer

✓ Accepted answer

I think I understand what you mean, you want to get a number of parts randomly to insert the fx? This can go in StarterCharacterScripts as a LocalScript. Next time include some code, normally people won't help otherwise.

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

local limbs_to_affect = 3

math.randomseed(tick())
-- you need to randomize the randomizer

local function random_limbs()
	local parts = {}
	-- table to store limbs
	for i,v in pairs(character:GetChildren()) do 
		local part = v:IsA("BasePart")
		-- Is part a part?
		if part then 
			-- If so insert into parts table
			table.insert(parts, v)
			-- (table, index or 1 on default, value)
		end
	end
	repeat table.remove (parts, math.random(#parts) ) wait() until #parts == limbs_to_affect
	-- will error if there aren't enough limbs, write an upgrade
	return parts
end

humanoid.Died:Connect(function()
	for i,v in pairs( random_limbs() ) do
		-- loop through our limbs table
		Instance.new('Fire', v ) 
		-- parent fx to part
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.