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

Whats the problem in this script?

local toucherpart = script.Parent toucherpart.Touched:connect(function(Part) if Part.Name = FootBall then local f=instance.new(''message'') f.Text = ''Goal!'' f.paretn = Workspace Wait(5) f:remove() end end)

2 answers

local toucherpart = script.Parent 
toucherpart.Touched:connect(function(Part) 
if Part.Name = FootBall then 
local f=instance.new(''message'')
f.Text = ''Goal!'' 
f.paretn = Workspace 
Wait(5) 
f:remove() 
end 
end)

So what you are trying to do is when a part hits a certain part, it says goal.

Problem 1:

All if statements must have 2 '==' to show operations. Also you need to use a string on 'Football' because roblox is looking for that, if it doesn't find a string, it will error.

Problem 2:

Your instance.new must have proper capitization If you are missing something it will error our (If you want, you can put the message lik)

Instance.new('Message')

(If you want, you can put the message like this so you don't have to manually set the parent)

local f = Instance.new('Message', workspace)

Problem 3:

The spelling and capitalization will error the script and won't work.

f.Parent = game.Workspace 

Problem 4:

Wait() has no capitalization. Remember, everything in code has to be proper.

wait(5)

Problem 5:

Roblox deprecated this statement. Meaning roblox doesn't recommend it for new work. Instead, use :Destroy() (plus capitalization)

f:Destroy()

That's all! Everything should work!

Finished code:

local toucherpart = script.Parent 
toucherpart.Touched:connect(function(Part) 
	if Part.Name == "FootBall" then 
		local f = Instance.new("Workspace", workspace) -- if you want, you can manually say f.Parent = game.workspace
		f.Text = "'Goal!'"
		f.Parent = game.Workspace
		wait(5) 
		f:remove() 
	end 
end)

If this works please hit that accept button!

If I did something wrong or if you need a better explanation of something, please comment and i'll get back to you.

local touchPart = script.Parent
touchPart.Touched:connect(function(part)
if part.Name = 'FootBall' then
local f = Instance.new('Message').Parent = workspace
f.Text = 'Goal!'
game:GetService('Debris'):AddItem(f,5)
end)

Maybe this.

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