i see now i forgot an “a” in Params, so it would be OverlapParams.new()
Yes, the blue underline has now been removed and the text is red.
its being angry . hmmm i should of pasted the code in roblox studio to check with the errors. Give me a second to do that
No, not a red line. The text is red. I think that means it’s a function
oh mb you said red underline so i thought something went wrong lol
Heres something I came up with your code that you’ve shown me
I have forgotten to say that anything under the parent of the ball will also be included in the
You actually can shorten the code without having two separate scripts doing the same thing actually. Which i am assuming
Heres a revised code you could use
-- In my opinion i wouldn't put scripts directly in workspace, but in serverscriptservice.
local RedGoal = workspace:WaitForChild("RedGoal")
local BlueGoal = workspace:WaitForChild("BlueGoal")
local Ball = workspace:WaitForChild("Ball")
local params = OverlapParams.new()
params.FilterDescendantsInstances = { Ball }
params.FilterType = Enum.RaycastFilterType.Whitelist
function Reset()
Ball.Anchored = true
Ball.Position = Vector3.new(10, 110.5, -3)
Ball.Position = Vector3.new(19, 3.799, 1.5)
resetRed()
resetBlue()
Ball.Anchored = false
Ball.AssemblyLinearVelocity = Vector3.new(0,0,0)
Ball.AssemblyAngularVelocity = Vector3.new(0,0,0)
end
function Check()
local redGoalParts = workspace:GetPartsInPart(RedGoal, params)
local blueGoalParts = workspace:GetPartsInPart(BlueGoal, params)
if table.find(redGoalParts, Ball) then
-- Give red points/logic
elseif table.find(blueGoalParts, Ball) then
-- Give blue points/logic
else return end
Reset()
end
game:GetService("RunService").HeartBeat:Connect(Check)
It works! I made it so that it prints “Goal”, but it prints like 60x everytime it touches, do I just add a wait function?
Hm, you could use an variable to store to disable the checking. So right when it hits, you can set the variable, like checking
, to false
, and have a if statement checking at the top if not checking then return end
then when it gets reset and stuff, you can set the checking variable back to true
Works, but the ball slows down in the air, is this my pc’s problem or the code’s?
It could be the physics of the roblox engine is dying, not sure really though. Do you have any fps drops or something like that, and does the slow falling of the ball happen when it touches a goal?
Ball.Touched:Connect(function(part)
if part.Name == “Goal” then
print(“Goal!”)
end
end)
I said the best alternative to .Touched
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.