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

Script doesn't work when i touch the button on touch?



function touched(hit) wait(.1) if hit.Parent~=nil then local h=hit.Parent:FindFirstChild("Humanoid") if h~=nil then if h.Health>0 then local s=hit.Parent:FindFirstChild("Shirt") local p=hit.Parent:FindFirstChild("Pants") local t=hit.Parent.Torso:FindFirstChild("roblox") if s~=nil then s:remove() end if p~=nil then p:remove() end h.MaxHealth=200 if t~=nil then if t.Texture=="http://www.roblox.com/asset/?id=3555194" then h.MaxHealth=500 <--------------------------i could cheat right here, but i like a fair game. :) else t:remove() end end h.Health=h.MaxHealth h.Health=h.Health-1 h.Parent.Head.BrickColor=BrickColor.new("Black") h.Parent:FindFirstChild("Torso").BrickColor=BrickColor.new("Light stone grey") h.Parent:FindFirstChild("Left Arm").BrickColor=BrickColor.new("Light stone grey") h.Parent:FindFirstChild("Left Leg").BrickColor=BrickColor.new("Light stone grey") h.Parent:FindFirstChild("Right Arm").BrickColor=BrickColor.new("Light stone grey") h.Parent:FindFirstChild("Right Leg").BrickColor=BrickColor.new("Light stone grey") end end wait(.5) end end script.Parent.Touched:connect(touched)

--http://www.roblox.com/asset/?id=3555194

3 comments

0

Place your code inside a code block, so it is easier to read..

0

Looks like you made the code block... Seems like you forgot to put the code in it. Put the code in-between the top and bottom lines when selecting the code block.

0

I put it in a code block for you, but you have everything on one line...

1 answer

✓ Accepted answer

It should work, it's probably because half of your code is green (meaning it is included in the "--", usually it is used to put notes in the script and will not be run by the script).

function touched(hit)
	task.wait(0.1)
	if hit.Parent ~= nil then
		local h = hit.Parent:FindFirstChildWhichIsA("Humanoid")
		if h ~= nil then
			if h.Health > 0 then
				local s = hit.Parent:FindFirstChild("Shirt")
				local p = hit.Parent:FindFirstChild("Pants")
				local t = hit.Parent.Torso:FindFirstChild("roblox") 
				if s ~= nil then
					s:remove()
				end
				if p ~= nil then
					p:remove()
				end
				h.MaxHealth = 200
				if t ~= nil then
					if t.Texture == "http://www.roblox.com/asset/?id=3555194" then
						h.MaxHealth=500 --i could cheat right here, but i like a fair game. :)
					else
						t:remove()
					end
				end
				h.Health = h.MaxHealth
				h.Health -= 1
				
				for _, limb in h.Parent:GetChildren() do
					if limb:IsA("BasePart") then
						if limb.Name == "Head" then
							limb.BrickColor = BrickColor.new("Black")
						else
							limb.BrickColor = BrickColor.new("Light stone grey")
						end
					end
				end
			end
		end
		task.wait(0.5)
	end
end

script.Parent.Touched:Connect(touched)

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