Hello, I’ve been working on a prison type game, and it’s just about ready to be released. I’m currently finalizing things and squashing bugs, however there’s this one issue I’m unable to solve.
Inside my prison soccer system, I have it where if a ball touches a part inside the goal, the it will score. However after shooting once, it doesn’t detect the ball. Can anyone help me with this?
So far I’ve reworked the code multiple times, and I’m not quite sure if I’m missing something important or if it’s just some bug with the touch function itself. The code below is what I’m using (the script is inside the goal part). Here’s a video so you know what I’m talking about.
robloxapp-20230519-1746391.wmv (2.6 MB)
script.Parent.Touched:Connect(function(hit)
if hit.Name == "Soccerball" and workspace.Soccerball.debounce.Value == false then
workspace.Soccerball.debounce.Value = true
script.Parent.Score.Value = script.Parent.Score.Value + 1
game.Workspace.soccerpart.goal:Play()
wait(2.5)
hit.Anchored = true
hit.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
hit.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
hit.Position = Vector3.new(156.986, 1478.785, 1249.021)
wait(2)
game.Workspace.soccerpart.goalstart:Play()
hit.Anchored = false
workspace.Soccerball.debounce.Value = false
end
end)
I’ve looked at many posts, and nothing matches my issue from my findings. I’d really appreciate any support on this, and thank you for your time.