the end) is for the “if humanoid then” so it close the function when the player touch it
local Part = game.Workspace.Part
Part.Value.Value = 200
local Part1 = game.Workspace.Part1
Part.Touched:Connect(function(touched)
local humanoid = touched.Parent:FindFirstChild(“Humanoid”)
if humanoid then
Part:Destroy()
Part1.Transparency = 0
end
if Part.Value.Value == 200 then
print(“Hello”)
end
end)
Cleaned up this code a bit and preserved the starting functionality so that it prints after touch.
i mean he asked for printing the “hello” idk if when touched
I mean, you’re completely right but you always should strive to fix the code without changing the functionality it had at the beginning, just a tip .
you’re right, im new in this website and i never helped a guy but thanks
It looks like there’s a small mistake in your code. The variable PartValue
is assigned the value of Part.Value == 200
, which is a boolean value (true
or false
). Later, you check if PartValue
is equal to 200, and if true, you print “Hello.” However, since PartValue
is a boolean, it will never be equal to 200.
Here’s the corrected code:
local Part = game.Workspace.Part
local Part1 = game.Workspace.Part1
Part.Touched:Connect(function(touched)
local humanoid = touched.Parent:FindFirstChild("Humanoid")
if humanoid then
Part:Destroy()
Part1.Transparency = 0
end
if Part.Value == 200 then
print("Hello")
end
end)
Now, it directly checks Part.Value == 200
within the Touched
event function, so it should print “Hello” when the condition is true.