Script isn't being seen

My Script isn’t being read at all anyone know what could be causing it?

print("Script Check")

if script.Parent.Touch.Value > 1 then
print(“Touch value checked”)
for i=1,script.Parent.Size.Y/25 do
print(“les go2”)
script.Parent.Parent.Door.CFrame = script.Parent.Parent.Door.CFrame+Vector3.new(0,.9,0)
end
end

Script
DoorController is the script

1 Like

If you add an else and print the value will it print?


if script.Parent.Touch.Value > 1 then
print(“Touch value checked”)
for i=1,script.Parent.Size.Y/25 do
print(“les go2”)
script.Parent.Parent.Door.CFrame = script.Parent.Parent.Door.CFrame+Vector3.new(0,.9,0)
end
else
print(script.Parent.Touch.Value)
end

Still doesn’t print, any other ideas?

Is this the whole script???

yeah it is, could that be an issue?

Well I see you’re lerping for a door animation. I believe you want to add an interval:

print('This script is running.')

local basePart = script.Parent
local doorPart = basePart.Parent:WaitForChild('Door')
local touchValue = basePart:WaitForChild('Touch')
local doorInterval = 0.1 --- Larger numbers are slower, smaller numbers are faster.

local function onTouchValueChanged()
	if touchValue.Value > 1 then
		print('The Touch value is over 1.')
		for i = 1, basePart.Size.Y / 25, 1 do
			doorPart.CFrame *= CFrame.new(0, 0.9, 0)
			task.wait(doorInterval)
		end
	end
end

onTouchValueChanged()
touchValue:GetPropertyChangedSignal('Value'):Connect(onTouchValueChanged)

Based on your parameters for the loop, I assume the door is very large. If you want this to happen whenever the Value property of the Touch value is changed, then you should connect it to the changed signal.

If this part of the code is incorrect, and I believe it is based on the context, you should make this number smaller. If you do not want a connection for this then you can just remove it, but if you want it to happen only once and when the Touch value is changed, add a debounce-esque mechanic here.

Where did you place this code, and is it a script or a local script?

Reading from the replies, I feel like everyone has missed the point of your question…

just a normal script, and i do think ppl strayed a lil bit

Could you please tell me where the script is located?

It’s in the post DoorController is the script in the LevelStart part

This is useless information, I need to know where LevelStart part is in, scripts do not run everywhere

within a part, within a folder, within the workspace

Is the script enabled? Also how are you testing it?

the script is enabled, and im testing it my play testing the game with the studio and changing the value of “Touch” above 2

You need to tell it to look for the changes. So try this but change the part to your part.

local part = workspace.LevelStart
local touch = part.Touch

local function check()
	if touch.Value > 1 then
		print("Touch value checked")
		for i=1,script.Parent.Size.Y/25 do
			print("les go2")
			script.Parent.Parent.Door.CFrame = script.Parent.Parent.Door.CFrame+Vector3.new(0,.9,0)
		end
	else
		print(script.Parent.Touch.Value)
	end
end
touch:GetPropertyChangedSignal("Value"):Connect(check)