I heard colletion service can be used to decrease the load of the server, and instead apply one script into parts with the collection tag, im trying to make a script whereas each of these parts (obstacles) when touched will explode the player on impact and it doesnt seem to work, does anyone know why this is happening?
2 Likes
You’re using CollectionService correctly but the syntax isn’t written correctly.
That’s why some words are underlined red.
Try this:
local CS = game:GetService("CollectionService")
for i, model in pairs(CS:GetTagged("Obstacle")) do
model.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Bomb = Instance.new("Explosion")
Bomb.BlastPressure = 100000
Bomb.BlastRadius = 10
Bomb.Position = model.Position
Bomb.Parent = model
end
end)
end
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.