Pretty simple question I have, why does this only work for one player? It may be me just being stupid but why does this ONLY affect one player?
local radiussphere = Instance.new("Part", landmine)
radiussphere.Anchored = true
radiussphere.CanCollide = false
radiussphere.Shape = Enum.PartType.Ball
radiussphere.Size = Vector3.new(25,25,25)
radiussphere.Position = landmine.Position
radiussphere.Transparency = 1
radiussphere.Touched:Connect(function(touched)
if touched.Parent:FindFirstChild("Humanoid") then
if touched.Name == "Torso" then
local char = object.Parent
gib_bomb(char)
end
end
end)
This isn’t the ENTIRE script but if you really need it I can edit the post.
This is serversided, everything about the script works but it for some reason only detects one player being touched. And when it does it detects it multiple times.
Basically removing the legs, but right now all it does is removes the legs of the person who touched it and fling them.
Script
local landmines = script.Parent:GetChildren()
local gibmodule = require(game:GetService("ServerStorage").Mediaman_Gibs)
local Players = game:GetService("Players")
local Characters = Players:GetPlayers()
local hit = {}
function fling(source)
local vf = Instance.new("VectorForce", source)
local at = Instance.new("Attachment", source)
vf.Force = Vector3.new(math.random(5000,8000),8500,math.random(5000,8000))
vf.Attachment0 = at
wait(.2)
vf:Destroy()
at:Destroy()
end
function gib_bomb(chr)
if chr and not table.find(hit, chr) then
table.insert(hit, chr)
fling(chr.PrimaryPart)
gibmodule.giblimb(chr, chr["Right Leg"], "Explosive", 80)
gibmodule.giblimb(chr, chr["Left Leg"], "Explosive", 80)
end
repeat
wait(.1)
until chr:FindFirstChildOfClass("Humanoid").Health <= 0
table.remove(hit, chr)
end
for _, landmine in pairs(landmines) do
if landmine.Name == "Landmine" or landmine.Name == "AntiTankLandmine" then
local debounce = false
local effects = game:GetService("ServerStorage"):WaitForChild("Explosive_Effects")
for _, effect in pairs(effects:GetChildren()) do
if effect:IsA("ParticleEmitter") then
local new = effect:Clone()
new.Parent = landmine
end
end
landmine:WaitForChild("Trigger").Touched:Connect(function(object)
if object.Parent:FindFirstChild("Humanoid") then
if debounce == false then
debounce = true
local radiussphere = Instance.new("Part", landmine)
radiussphere.Anchored = true
radiussphere.CanCollide = false
radiussphere.Shape = Enum.PartType.Ball
radiussphere.Size = Vector3.new(25,25,25)
radiussphere.Position = landmine.Position
radiussphere.Transparency = 1
radiussphere.Touched:Connect(function(touched)
if touched.Parent:FindFirstChild("Humanoid") then
if touched.Name == "Torso" then
print("got")
local char = object.Parent
gib_bomb(char)
end
end
end)
for _, effect in pairs(landmine:GetChildren()) do
if effect:IsA("ParticleEmitter") then
effect:Emit(20)
end
end
local sound = Instance.new("Sound", landmine)
sound.PlayOnRemove = true
sound.Volume = 1.2
sound.RollOffMaxDistance = 250
sound.SoundId = "rbxassetid://13404155709"
landmine.Transparency = 1
landmine.CanCollide = false
sound:Destroy()
wait(3.8)
landmine:Destroy()
end
end
end)
end
end
Raycasts would certainly be better, however I never had to use raycasts on any of my projects so I can’t help with that.
Based on the roblox docs, you could try to use BasePart | Roblox Creator DocumentationonTouch and onTouchEnded, store the player who already toutch the part, and remove them when they don’t anymore (onTouchEnded). Then you just verify if the user already touched the part or not.