Okay, so I’m trying to create a walk-on-water serverscript using collisiongroups, as seen here:
local ps = game:GetService("PhysicsService")
local module = require(game.ServerScriptService.Modules.jesusPeople) -- script for walk-on-water user IDs
local localplayer = "Character"
local water = "Water"
-- Create two collision groups
ps:CreateCollisionGroup(localplayer)
ps:CreateCollisionGroup(water)
ps:SetPartCollisionGroup(script.Parent, water)
local function setGroups(character)
for _, child in ipairs(character:GetDescendants()) do
if child:IsA("BasePart") then
print("It's a basepart.")
ps:SetPartCollisionGroup(child, localplayer)
ps:CollisionGroupSetCollidable(localplayer, water, true)
end
end
end
local function onCharacterAdded(character)
print("characterAdded")
setGroups(character)
end
game.Players.PlayerAdded:Connect(function(player)
for i, v in ipairs(module.gods) do
print(v)
if player.UserId == v then
print("player's userid is equal to one of the IDs in the module.gods table")
player.CharacterAdded:Connect(onCharacterAdded)
end
end
print("playerAdded!")
end)
The modulescript it calls contains the following code:
local module = {
gods = {
25297190, -- me
109844063, -- superstrongtitan
}
}
return module
Pay close attention to
ps:CollisionGroupSetCollidable(localplayer, door, false)
In regards to the large, former block of code, there are no error outputs. In fact, everything prints nicely. It even works, but only half the time. In the line of code above ^^^, the code works. When I set the water to CanCollide and run this script, it allows me to fall through it, easy peasy.
The problem shows itself when I set it to Non-CanCollide and set
ps:CollisionGroupSetCollidable(localplayer, door, true)
to true instead of false.
Upon changing it, yes, there are no errors, and everything prints fine.
Does anyone know what’s going on here? I’ve never had an error like this before…
Please feel free to share your thoughts.