In my minigolf game, i’m trying to make your ball the only one you can hit so griefing other players isn’t possible in the game.
Currently, I have it set up so that when a player joins the game it makes a collision group for your ball and your putter in a collision group. This all works fine but it is at line 16 that the error is from where I try to set the putter to not be able to collide with other player’s balls.
local PhysService = game:GetService("PhysicsService")
game.Players.PlayerAdded:Connect(function(player)
local ball = PhysService:RegisterCollisionGroup(player.Name.." Ball")
PhysService:CollisionGroupSetCollidable(player.Name.." Ball" ,"Player",false)
local ball = PhysService:RegisterCollisionGroup(player.Name.." Putter")
PhysService:CollisionGroupSetCollidable(player.Name.." Putter" ,"Player",false)
PhysService:CollisionGroupSetCollidable(player.Name.." Putter" ,"Default",false)
PhysService:CollisionGroupSetCollidable(player.Name.." Putter" ,"Wall",false)
for _, groups in pairs(PhysService:GetRegisteredCollisionGroups()) do
if groups["Name"] ~= player.Name.." Ball" or player.Name.." Putter" or "Default" or "Wall" then
PhysService:CollisionGroupSetCollidable(player.Name.." Putter" , groups ,false)
end
end
end)
If anyone could help I would greatly appreciate it and if you know a better way I could do this feel free to tell me!