Hello! I’m having a problem on a script that when a part gets touched on the Workspace, it pops up an GUI and makes a typewriter text effect, but i get an error and it just executes by itself without the player having to touch the part, here’s the script:
local HitBox = game.Workspace.HitBox
local DialogueBox = game.StarterGui.DialogueGui.DialogueFrameOutline
local DialogueText = DialogueBox.DialogueFrame.Dialogue
local function typeWriter(s)
local newString
for i = 0, s:len(), 1 do
newString = s:sub(1, i)
DialogueText.Text = newString
wait(0.01)
end
end
local function onTouch()
HitBox:Destroy()
DialogueBox.Visible = not DialogueBox.Visible
typeWriter("Hello! Welcome to the tutorial!")
wait(5)
end
HitBox.Touched:Connect(onTouch()) --ERROR: Attempt to connect failed: Passed value is not a function
The error is on the line 20 if you didn’t notice, how can i fix this?