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

How can I make this script that turns humanoids into stone work?

I am making a script that turns players into stone when they touch its parent, I made the script but when I try it, nothing happens. although the script is small, I would greatly appreciate the help. here is the script:

function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if h~=nil then
	local c = h.Parent:GetChildren()
	c.UsePartColor = true
	c.Material = ("Slate")
	c.BrickColor = BrickColor.new(1)
	c.Anchored = true
end

connection = bin.Touched:connect(onTouched) 

1 answer

✓ Accepted answer

Well, you made a couple errors. Let me show you what you should fix:

function onTouched(part)
    local h = part.Parent:findFirstChild("Humanoid")
    if h~=nil then
	    local c = h.Parent:GetChildren()
		for index, item in pairs(c) do -- This is a for loop that goes through the whole character.
			if item:IsA("Part") then -- Check to see if the item is a part.
			    item.Material = Enum.Material.Slate -- To change the material you use Enum.Material.MATERIAL. We're using Enum.Material.Slate because that's the material you want.
			    item.BrickColor = BrickColor.new("Fossil") -- This is how you use BrickColor.new(). You need to put inside of quotations the name of the color!
			    item.Anchored = true 
			end
		end
    end -- You missed this end!
end

connection = bin.Touched:connect(onTouched) 

You're good to go! I provided the explanation inside of the script using comments.

Hope I helped! :)

7 comments

0

Thank you very much, but it does not seem to work.

0

Well, is bin a part?

0

I don't think so

0

What's it's ClassName?

0

oh, it is a part

0

but I would also like it to work on Unions and Wedges

0

I found the problem and fixed it, thank you very much for your help, it means a lot

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