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

(Easy) My script wont print when a part in workspace is touched?

it's underlines end) I don't know whats wrong

local CFrameTester = script.Parent

if script.Parent.Parent.Tester1.Touched:Connect(function()
		
		print("it worked!")
		
	end)
		

4 comments

0

DO NOT add an if when checking if a part was touched

0

You didn't call the function. after the end put "

0

Instead of an if statement use a function. "function partTouched (onTouch)

0

and then after the function put "script.Parent.Parent.Tester1.Touched:Connect(partTouched)"

2 answers

✓ Accepted answer

Your mistake was really simple: do NEVER put an if statement if you are making a function. That being said, just remove the if statement and you will be good to go!

local CFrameTester = script.Parent

script.Parent.Parent.Tester1.Touched:Connect(function()

        print("it worked!")

    end)

This is very simple. So insert a part in the workspace and insert a script in the part and type this

Script

local function onTouch(hit)
	print("it worked!")
end

script.Parent.Touched:Connect(onTouch)

Now when you touch it, it will print "It Worked"

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