What do you want to achieve? I wanna set the eh player collision group
What is the issue? It doesnt work, collide with players and zombies for my game
What solutions have you tried so far? None yet
what’s wrong with my code
local Players = game:GetService("Players")
local PhysicsService = game:GetService("PhysicsService")
Players.PlayerAdded:Connect(function(player)
local groupId = unknown because i dont want to show it
local role = player:GetRoleInGroup(groupId)
local cashValue = 500
if role == "Owner 🔨" then
cashValue = 1000000
elseif role == "Developer / Admin 🔧🛡️" then
cashValue = 100000
elseif player:IsInGroup(groupId) then
cashValue = 600
end
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = cashValue
cash.Parent = player
local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = player
local placedTowers = Instance.new("IntValue")
placedTowers.Name = "PlacedTowers"
placedTowers.Value = 0
placedTowers.Parent = player
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cashStats = Instance.new("IntValue")
cashStats.Name = "Cash"
cashStats.Value = cash.Value
cashStats.Parent = leaderstats
cash:GetPropertyChangedSignal("Value"):Connect(function()
cashStats.Value = cash.Value
end)
cash.Changed:Connect(function()
cashStats.Value = cash.Value
end)
player.CharacterAdded:Connect(function(character)
for i, object in ipairs(character:GetDescendants()) do
if object:IsA("BasePart") then
object.CollisionGroup = "Player"
end
end
end)
end)
Make sure you use the inbuilt roblox collision group editor so they have the properties that you desire, in most cases you cant just create a collision group and set it a day, you need to set how players will collide with zombies via the editor
i already did that before, also i tested on my oldest version on my game and it works perfectly i even tried using the old script and it worked but ill lose all the changes of group, etc if i do that. (Mob is Zombie)
Try setting the collision when the player enters the game and the player resets.(loadcharacter)
i mean:
local Players = game:GetService("Players")
local PhysicsService = game:GetService("PhysicsService")
Players.PlayerAdded:Connect(function(player)
local groupId = unknown because i dont want to show it
local role = player:GetRoleInGroup(groupId)
local cashValue = 500
if role == "Owner 🔨" then
cashValue = 1000000
elseif role == "Developer / Admin 🔧🛡️" then
cashValue = 100000
elseif player:IsInGroup(groupId) then
cashValue = 600
end
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = cashValue
cash.Parent = player
local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = player
local placedTowers = Instance.new("IntValue")
placedTowers.Name = "PlacedTowers"
placedTowers.Value = 0
placedTowers.Parent = player
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cashStats = Instance.new("IntValue")
cashStats.Name = "Cash"
cashStats.Value = cash.Value
cashStats.Parent = leaderstats
cash:GetPropertyChangedSignal("Value"):Connect(function()
cashStats.Value = cash.Value
end)
cash.Changed:Connect(function()
cashStats.Value = cash.Value
end)
for i, object in ipairs(player.Character:GetDescendants()) do
if object:IsA("BasePart") then
object.CollisionGroup = "Player"
end
end
player.CharacterAdded:Connect(function(character)
for i, object in ipairs(character:GetDescendants()) do
if object:IsA("BasePart") then
object.CollisionGroup = "Player"
end
end
end)
end)