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

How do I make a blood puddle when someone gets hurt?

As in Catching Fire when you get hurt a blood puddle forms until the map clears I want that but I want it so it goes away after 1 minute.

2 answers

✓ Accepted answer

First of all create a localscript and put it in the player, once you've done that set up an anonymous function to fire when the humanoid takes damage.

local hum = script.Parent.Humanoid
local LastHealth = hum.Health
local maxSize = 5 -- Determines the maximum size of the blood pool

script.Parent.Humanoid.HealthChanged:connect(function(Health)
	local change = math.abs(LastHealth - Health) -- this will let us create a bloodpool proportional to the change ofHealth
	if LastHealth > Health then
		local Pool = Instance.new("Part", game.Workspace) -- creates the new part and sets it's values
		Pool.Anchored = false
		Pool.BrickColor = BrickColor.new("Bright red")
		Pool.FormFactor = "Custom"
		Pool.Size = Vector3.new((change/hum.MaxHealth)*maxSize, 0.2, (change/hum.MaxHealth)*maxSize) --Defined maxSize on Line 3 of the script, make it what ever you want. 
		Pool.TopSurface = "Smooth"
		Pool.BottomSurface = "Smooth"
		Pool.CFrame = CFrame.new() + script.Parent.Torso.CFrame * Vector3.new(0, -3, 0) -- should place it below the players feet.
		--Optional add a mesh here to make it round.
		Pool.CanCollide = false;
		Pool.Touched:connect(function(hit)
			if not hit.Parent:FindFirstChild("Humanoid") then
				Pool.Anchored = true
			end
		end)
		Spawn(function()		-- spawns this function on a separate thread so it doesn't stall this one
			wait(60)
			Pool:Destroy() -- destroys the pool after 60 seconds.
		end)
	end
	LastHealth = Health -- sets LastHealth to Health so that next time the script runs change can be calculated correctly
end)

Try this out and see if it works :).

To make this work for all players add a script to the workspace, then add a localscript to that script with the disabled property checked. Add the above code to the localscript.

In the script use this code

game.Players.ChildAdded:connect(function(Player) -- fires when a player joins the game
	Player.CharacterAdded:connect(function(Character) -- fires when it's character is added
		local poolScript = script.LocalScript:Clone() -- clones the localscript
		poolScript.Parent = Character -- parents it to the character
		poolScript.Disabled = false -- enables it
	end)
end)

What this will do is clone the localscript containing the pool code into each of the players characters when they join the game and whenever they respawn.

EDIT: So I've compiled the localscript at the top for you, it's in one part now.

Layout in Explorer:
Workspace
-Script (2nd codeblock goes here)
--LocalScript (1st codeblock goes here)

16 comments

0

I'm new to scripting how exactly do I set up the anonymous function and stuff like that XD

1

put a script in the humanoid and copy and paste the code, just make sure to read the comments ( the green text after two dashes) and try and understand what it's doing.

0

What if I want it to affect everyone not just the humanoid

1

you put this in the players when they join the game

0

So in the players tab of explorer?

1

sort of, I'll update my answer with an explanation.

1

Updated

0

oh okay thx C:

0

I tried it and it didn't work can u combine the 1st 2 into 1 for me I'm new at this XD

0

I'll fix it up and put it together for you, I included a few typos, I'll let you know when it's updated.

0

thanks

0

done

0

thanks

0

Still didn't work :C what exactly is the code block i might've been missing that

0

That's just the block of code shown above, if you click the icon on the top right corner of it when you hover your mouse over it, you can copy it all.

0

Yeah I did that and it still didn't work :C

When you script this, it would be a good idea to make it a function, then you can just call it every time someone dies :3

PS, i also play catching fire x3

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