local remote = game.ReplicatedStorage.Remotes.MeraLogia remote.OnServerEvent:Connect(function(plr, char) local UpperTorso = plr.Character:WaitForChild("UpperTorso") local dmg = false local arm = plr.Character.LeftHand local LeftFoot = plr.Character.LeftFoot local RightFoot = plr.Character.RightFoot local RightHand = plr.Character.RightHand UpperTorso.Touched:Connect(function(hit) if hit then dmg = true local a = game.ReplicatedStorage.MeraMeraMoves.fef:Clone() a.Name = "a" a.Parent = UpperTorso end end) UpperTorso.TouchEnded:Connect(function(en) if en then UpperTorso:WaitForChild("a"):Destroy() end end) end)
so if i touch something i want the effect to be in the uppertorso and it works but sometimes i mean a lot of times the effect stays there when it not even touching and when im touching something it wont add the effect sometimes how do i fix this??
When a touched function works, but not the way you'd expect it to, it probably needs a debounce. Try making the script check if there already is an "a" in UpperTorso, so that an extra "a" isn't created.
local remote = game.ReplicatedStorage.Remotes.MeraLogia remote.OnServerEvent:Connect(function(plr, char) local UpperTorso = plr.Character:WaitForChild("UpperTorso") local dmg = false local arm = plr.Character.LeftHand local LeftFoot = plr.Character.LeftFoot local RightFoot = plr.Character.RightFoot local RightHand = plr.Character.RightHand UpperTorso.Touched:Connect(function(hit) if hit then local already = UpperTorso:FindFirstChild("a") if not already then dmg = true local a = game.ReplicatedStorage.MeraMeraMoves.fef:Clone() a.Name = "a" a.Parent = UpperTorso end end end) UpperTorso.TouchEnded:Connect(function(en) if en then UpperTorso:WaitForChild("a"):Destroy() end end) end)
What probably happened is that when the player walked into whatever thing, the Touched event fired more than one time for the UpperTorso, creating multiple "a"'s. The touchEnded function only destroys one of the a's, so there are some remaining ones.