So basically I kinda suck with CollisionGroups, but ignoring this, I wanted a part that’s being cloned from ReplicatedStorage to not collide with players, however, it keeps throwing me an error which I don’t really understand. Can someone help?
Here is my script.
--local script in StarterGUI
local fakeHand = game:GetService("ReplicatedStorage"):WaitForChild("fakeHand")
function MakeFakeHand()
local newHand = fakeHand:Clone()
newHand.Parent = player.Character
newHand.CFrame = player.Character:WaitForChild("RightHand").CFrame
--Fire server for newHand collision group properties.
game.ReplicatedStorage:WaitForChild("newHandEvent"):FireServer(newHand)
local weld = Instance.new("WeldConstraint", newHand)
weld.Part0 = newHand
weld.Part1 = player.Character:WaitForChild("RightHand")
end
MakeFakeHand()
--Server script in ServerScriptService
task.wait(0.1) --Wait for "Players" collision group to load (doesn't seem to work though).
local PhysicsService = game:GetService("PhysicsService")
game.ReplicatedStorage.newHandEvent.OnServerEvent:Connect(function(plr, newHand)
--Set collision status of newHand to not collide with players.
local newHandcollisionGroup = PhysicsService:CollisionGroupSetCollidable("newHandCollisionGroup", "Players", false)
PhysicsService:SetPartCollisionGroup(newHand, newHandcollisionGroup)
end)
It keeps saying throwing an error that says, “Both collision groups must be registered.” and I really don’t know how to fix it.
Ohhhhh you know what I did? I accidentally renamed the collision group that I was calling in the script newHandCollisionGroup while the collision group itself was fakeHandCollisionGroup…
Sorry guys, my mistake!!
However, I do have a new problem where it throws an error saying Parameter 1 must be BasePart in SetPartCollisionGroup.
task.wait() --Wait for "Players" collision group to load.
local PhysicsService = game:GetService("PhysicsService")
game.ReplicatedStorage.newHandEvent.OnServerEvent:Connect(function(plr, newHand)
--Set collision status of newHand to not collide with players.
PhysicsService:CollisionGroupSetCollidable("fakeHandCollisionGroup", "Players", false)
PhysicsService:SetPartCollisionGroup(newHand, "fakeHandCollisionGroup")
end)
Well, if you are creating the Part on the Client, you are basically giving the Server a nil value as it doesnt exist there, so you should probably create it on the server.