Projectiles work well in studio but work differently in-game

Hello, I have been making a really basic shotgun tool where the projectiles when colliding with the ground spread particles and disable their flight function. When testing in the studio it worked well but when playing in-game the bullets collide with each other.

I was looking for solutions in developer hub but they didn’t work for some reason (probably because I am 1% experienced in scripting)

in studio:

in-game: (problem)

The script is too simple so I’ll put almost the entire script here lol

function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if h~=nil then
		
		h:TakeDamage(5)
		s:Play()
		if string.find(part.Name, "Leg") ~= nil or string.find(part.Name, "Arm") ~= nil or string.find(part.Name, "Head") ~= nil or string.find(part.Name, "Torso") ~= nil then
blo:Clone()
blo.Parent = part
blo.Blood:Emit(7)
	wait(3)
	blo:Destroy()
		end
else
		wait(0.07)   -------This is where my script starts the problem in the game.
		local b = part.Parent:findFirstChild("Bullet")
		if  b then
				ss:Play()
		local ddd = ola:WaitForChild("RocketScript")
		ddd:Remove()
	
				de.piedrita:Emit(5)
				de.smokii:Emit(7)
				wait(3)
		end
	end
end

script.Parent.Touched:connect(onTouched)

Surely this is a too obvious problem and I am very stupid (I also hope you can understand everything I wrote since I am using Google Translate)

When you do
switch else to

elseif part.Name~= "Bullet" then

this is assuming that the bullet is named “Bullet”

2 Likes

this is potentially due to network ownership, try using this method on each of the projectiles in your script, before they are parented to workspace:

local clone = projectile:Clone()
clone:SetNetworkOwner()
clone.Parent = workspace
2 Likes

Don’t execute the function when other bullets trigger a bullet’s Touched event to fire.
if part.Name == "Bullet" then return end

1 Like

now it works correctly in game!! thank you :))))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.