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

Field Goal not working how I wanted it to work?

This only works if my character has the football and touches the part, and it will say, "Field goal is good", but it doesn't work when the football is thrown at the part. I want it to where if the football hits the part it says Field goal is good instead of having to get my character to touch it.

name = "Football" 
debounce = false 

msg = Instance.new("Hint") 
msg.Text = "Field Goal Is GOOD!" 

function onTouched(hit) 

if (debounce==false) and (hit.Parent.Name==name) then 

debounce = true 

msg.Parent = game.Workspace 
wait(5) 
msg.Parent = nil 

debounce = false 

end 
end 

script.Parent.Touched:connect(onTouched) 

1 answer

Its checking if the hit parts PARENT is the name, it should check if both hits name is "Football" and hit.Parent.

name = "Football" 
debounce = false 

msg = Instance.new("Hint") 
msg.Text = "Field Goal Is GOOD!" 

function onTouched(hit) 

	if (debounce==false) )then 

		if (hit.Parent.Name == name) or (hit.Name == name) then

			debounce = true 

			msg.Parent = game.Workspace 
			wait(5) 
			msg.Parent = nil 

			debounce = false 

		end
	end 
end 

script.Parent.Touched:connect(onTouched) 

3 comments

0

I agree with your answer, but it seems that hit.Parent and hit have the same name (on line 11 in your script).

0

its because when he throws the ball at the field goal hit.Parent wouldnt be named "Football" but if the player is holding it then hit.Parent is "Football", hence the if or statement

0

So I tried what you gave me but this time the messaged didn't even show up even tho I threw the football and touched it

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