What do you want to achieve?
I want to make kitchen oven which flame player when click on switch
What is the issue?
local plate = script.Parent.Parent.plate
local btn = script.Parent.ClickDetector
btn.MouseClick:Connect(function()
plate.BrickColor = BrickColor.new("Really red")
if plate.Parent:FindFirstChild("Humanoid") then
plate.Parent.Humanoid:TakeDamage(10)
end
end)
I make condition but its not working
Can you fix my script pls.
Either way you need to define which player used the click detector in the function like this:
btn.MouseClick:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
if "Put the condition here" then
Humanoid:TakeDamage(10)
end
end)
local plate = script.Parent.Parent.plate
local btn = script.Parent.ClickDetector
local switch = script.Parent
local activated = false
btn.MouseClick:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
if not(activated)then
plate.BrickColor = BrickColor.new("Deep blue")
switch.BrickColor = BrickColor.new("Really red")
if Humanoid then
Humanoid:TakeDamage(10)
end
activated = true
else
switch.BrickColor = BrickColor.new("Medium stone grey")
activated = false
end
end)
I try to make this with plate too but same problem
local plate = script.Parent.Parent.plate
local btn = script.Parent.ClickDetector
local switch = script.Parent
local activated = false
btn.MouseClick:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
local Humanoid = char:WaitForChild("Humanoid")
if not(activated)then
plate.BrickColor = BrickColor.new("Deep blue")
switch.BrickColor = BrickColor.new("Really red")
if plate:FindFirstChild(Humanoid) then
Humanoid:TakeDamage(10)
end
activated = true
else
switch.BrickColor = BrickColor.new("Medium stone grey")
activated = false
end
end)
if plate.Parent:FindFirstChild(“Humanoid”) then
here you are checking if the oven has a humanoid, not the player
local plate = script.Parent.Parent.plate
local btn = script.Parent.ClickDetector
btn.MouseClick:Connect(function(player) --added the player in brackets basically telling the script who pressed the button
plate.BrickColor = BrickColor.new("Really red")
player.Character.Humanoid:TakeDamage(10) --gets the players character and takes damage
end)
you dont need the if statement since only a player with a character and a humanoid can press it
yeah you want the player to take damage and a plate to turn red when you click a button right?
if you mean that you want a fire to be on a player then:
local plate = script.Parent.Parent.plate
local btn = script.Parent.ClickDetector
btn.MouseClick:Connect(function(player)
fire = Instance.new("Fire")
fire.Parent = player.Character.HumanoidRootPart
plate.BrickColor = BrickColor.new("Really red")--added the player in brackets basically telling the script who pressed the button
player.Character.Humanoid:TakeDamage(10)
wait(5)
fire.Enabled = false
wait(3)
fire:Destroy()
end)
local plate = script.Parent.Parent.plate
local btn = script.Parent.ClickDetector
btn.MouseClick:Connect(function(player)
fire = Instance.new("Fire")
fire.Parent = player.Character.HumanoidRootPart
plate.BrickColor = BrickColor.new("Really red")--added the player in brackets basically telling the script who pressed the button
player.Character.Humanoid:TakeDamage(10)
wait(5)
fire.Enabled = false
wait(3)
fire:Destroy()
end)
I dont need fire, just damage. I say it simple
I want to make kill brick but killing is happen when i click on other part
So I make something like this
local plate = script.Parent.Parent.plate
local btn = script.Parent.ClickDetector
local switch = script.Parent
btn.MouseClick:Connect(function()
switch.BrickColor = BrickColor.new("Really red")
plate.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid:TakeDamage(10)
end
end)
end)
But some guy told me that function in function is wrong