So i am making a game that has a model touch a part, but it has a onTouch script inside that part and when the model hits it, nothing happens. I think this is because of the "(hit)" thing, but I am not completly sure.
function onTouched(hit) script.Parent.Transparency = 1 script.Parent.Parent.Sound:Play() end
(Sorry if my scripting isn't that long, also note I'm a beginner scripter so I don't know much yet.)
First of all, you're not connecting the function to any event. An event in rblx.Lua is basically a way to trigger something. One thing that I see a lot of beginners do is think that the name of the function will trigger the function, which actually the event triggers it. So you should have:
function onTouched() -- removed the hit argument since it is pointless for now script.Parent.Transparency = 1 script.Parent.Parent.Sound:Play() end script.Parent.Touched:Connect(onTouched) -- this line is what tells the function "onTouched" to run
The event "Touched" is a predefined event that triggers something whenever "script.Parent" in this case, is touched.