Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i will deal damage without the .Touched ?

i made a script that makes a light ball but now i want it to deal damage then i tried to use a .Touched event, but the .Touched event is invalid to localscript and script can someone tell me how to make the ball deal damage without the .Touched event ? This is my script

Light ball (LocalScript)

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

function OnKeyDown(key)
	key = key:lower()
	if key == 'z' then
		x = Instance.new('Part')
		x.TopSurface = 'Smooth'
		x.CanCollide = false
	    x.BottomSurface = 'Smooth'
		x.Shape = 'Ball'
		x.Material = 'Neon'
		x.Size = Vector3.new(2.51, 2.51, 2.51)
		x.BrickColor = BrickColor.new('Deep orange')
		x.Parent = game.workspace
		pt = Instance.new('PointLight',x)
		pt.Brightness = 10000000
		pt.Range = 20
		pt.Color = Color3.new(Color3.fromRGB(255,255,0)) 
		p = Instance.new('ParticleEmitter')
		p.Parent = x
		p.Rate = 5
		p.Texture = 'rbxgameasset://Images/ParticleTest'
		p.Color = ColorSequence.new(Color3.fromRGB(255,255,0),Color3.fromRGB(255, 170, 0))
		p.VelocitySpread = 360
		p.Speed = NumberRange.new(3)
		p.Lifetime = NumberRange.new(2.1,5)
		p.Size = NumberSequence.new(1)
		p.Transparency = NumberSequence.new(0.16)
		p.LightEmission = 1
		y = Instance.new('BodyVelocity')
		y.maxForce = Vector3.new(math.huge,math.huge,math.huge)
		y.velocity = plr.Character.UpperTorso.CFrame.lookVector
		y.Parent = x
		x.CFrame = plr.Character.UpperTorso.CFrame*CFrame.new(0,0,-3)
		wait(15)
		x:remove()
	end
end
mouse.KeyDown:connect(OnKeyDown)

--Damage (Script inside the LocalScript)

function Damage(l)
	if l.Parent:FindFirstChild('Humanoid') then
		for i = 1,30
                l.Parent.Humanoid.Health = l.Parent.Humanoid.Health - 1
		end
	end

script.Parent.Touched:connect(Damage)

3 comments

0

Have you tried adding a code that will clone the damage script into the ball after it's been fired? i.e. The server-side is within the localscript, and the localscript clones the damage script into the ball. Also, your damage function isn't set up to deal damage.

0

oh yeah sorry i was trying too much things then to decrease the code size i put print to see if the .Touched works.

0

and no.I didnt try. thanks.

1 answer

✓ Accepted answer

if the Script is in Localscript, then nothing is being touched, change the path to

function Damage(l)
    if l.Parent:FindFirstChild('Humanoid') then
        print("found")
        end
    end
game.Workspace:WaitForChild("Part").Touched:connect(Damage)

it's WaitForChild("Part") because that's the name of the part when you first make

if you got other things in workspace named "Part" then you need to the set the lightball's name by

x.Name = "LightBall" 

3 comments

0

There now everything in the world is right again.

0

thanks. =3.

0

Can u help me again ?How can I make it deal damage everytime it finds LightBall ?

This discussion is preserved as it was. New answers, comments, and votes are closed.