When running the script why isnt it printing hello?


local Part = game.Workspace.Part
local PartValue = Part.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 PartValue == 200 then
print(“Hello”)
end
end)

5 Likes

Could you add footage of your output?

No errors in output

You have to reference Part.Value.Value since Value is just the object and not the value and since you use comparisions PartValue is just a boolean and can be just used like that

local Part = game.Workspace.Part
local PartValue = 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 PartValue then
print(“Hello”)
end
end)


still not printing

does this need to be in a part, mines in SSS

this wont work for 2 reasons:

  1. the “==” is only to check if a value is like the other value;
  2. instead of “Part.Value” you should do “Part.Value.Value = 200”

Part.Value.Value = 200 is the correct line

I tried the 2 =s but it didnt print it in the output

It isn’t printing because the value of the Value inside the part is simply 0. You should set the value to 200 if you want it to print.

Part.Value.Value = 200

local Part = game.Workspace.Part
local PartValue = Part.Value.Value

PartValue = 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 PartValue == 200 then
print(“Hello”)
end
end)

try this and lemme know

1 Like


Still nothing in output

It’s under a .Touched event, have you tried triggering it and seeing what happens? Because this code is 100% correct.

Slight edit:

local Part = game.Workspace.Part
local PartValue = Part.Value.Value

PartValue = 200

Should instead be:

local Part = game.Workspace.Part
Part.Value.Value = 200

Sorry im quite new to coding, what do you mean by that

local Part = game.Workspace.Part
local PartValue = Part.Value.Value

PartValue = 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
end)

if PartValue == 200 then
print(“Hello”)
end

try this or else i will make a new one

Yay! Awesome it works thank you so much!

1 Like

I would argue this is wrong though. It’s not the intended functionality, besides the Value in the part is still equal to 0.

i dont understand why u dont need an end) at the end…