so i added throwable flares to my game, which are supposed to weld to whatever they hit and it works fine, but for some reason the touched event doesnt always fire or it fires with a delay and the flare just falls underground (even though the handle’s CanCollide property is set to true?). i havent had this issue with other sticky grenades like the c4. the touched event is being handled on the server and the flares networkship owner is set to nil (server). any ideas?
Can you please provide the code, I want to make sure that your code isn’t written incorrectly
You should set the network owner to the person who threw the flare.
I haven’t done touches with terrain ever, because I don’t make terrain.
nade.PrimaryPart.Touched:Connect(function(part)
local charParts = {}
for i,v in pairs(plr.Character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("MeshPart") then
table.insert(charParts,v)
end
end
if not table.find(_G.Blacklist,part) and not table.find(charParts,part) and part.Parent ~= plr.Character and nade.Handle:FindFirstChild("TouchedWeld") == nil and nade.Handle.Anchored == false then
print("touched")
if part.Name ~= "Terrain" then
nade.FX.Rotation = Vector3.new(0,0,-90)
local weld = Instance.new("WeldConstraint",nade.PrimaryPart)
weld.Name = "TouchedWeld"
weld.Part0 = nade.PrimaryPart
weld.Part1 = part
else
nade.FX.Rotation = Vector3.new(0,0,-90)
nade.PrimaryPart.Anchored = true
nade:SetPrimaryPartCFrame(CFrame.new(nade.PrimaryPart.Position)*CFrame.Angles(math.rad(nade.PrimaryPart.Rotation.X),math.rad(nade.PrimaryPart.Rotation.Y),math.rad(nade.PrimaryPart.Rotation.Z)))
end
end
this is the touched event
There’s a thing in game design where some tools can sometimes pierce through objects by frames.
A kart is going at a forward direction, it moves at a forward velocity. In real life, the kart would hit the wall and crash, but in games, the kart could sometimes pierce and go through the wall.
This has to do with framerate sometimes, and it seems to be what is happening to you.
A solution to it I would suggest you do is to make an external hitbox around the flare, bigger than the flare, and use the hitbox for collision instead. Because if the small tiny flare is the one detecting collisions, there’s a higher chance it will pierce through. With a bigger hitbox collission, that chance should get reduced up until the probability of it happening is not one that happens often in game (we’re talking a flare that is going 5 million km/s)
i think that could have been the problem. i guess the handle part was too small. i made it a little bit bigger and it seems to be better
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.