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

Why is my script saying " FindFirstChild is not a valid member of RBXScriptSignal"'?

I have tried everything upon changing the code, looking at the object browser and searching up similar events on other websites, but nothing had came across the same event as this.

Im not asking you to do all the work, but if you could explain to me what I did wrong and how I could fix it then that would be appreciated!

I have made a protection bubble out of a Ball that surrounds me inside it when I press the Q button. I wanted it to kill players that tried to touch it by looking if my localplayer name was theirs, and if it wasnt, it would kill them, but I have not used this script yet. Ty for your help and time!

Code:

local player = game.Players.LocalPlayer
local character = player.Character
local terrain = game.Workspace.Terrain
local ammo = 1

local x = Instance.new("Part")
	x.Size = Vector3.new(48,48,48)
	x.Transparency = 0.2
	x.Shape = "Ball"
	x.CanCollide = false
	x.Anchored = true
	x.BrickColor = BrickColor.new("Electric blue")
	x.TopSurface = "Smooth"
	x.BottomSurface = "Smooth"
	
local p = Instance.new("ParticleEmitter")
local f = Instance.new("ForceField")
local s = Instance.new("Smoke")
local sl = Instance.new("SurfaceLight")
local sp = Instance.new("Sparkles")
local color1 = Color3.new(121, 244, 255)
local color2 = Color3.new(226, 0, 255)

	p.Parent = x
	p.Color = ColorSequence.new(color1, color2)
	p.Rate = 250
	p.Speed = NumberRange.new(25)
	p.Size = NumberSequence.new(5)
	p.LightEmission = 100
	p.VelocitySpread = 808080
	
		s.Parent = x
		s.Color = Color3.new(75, 255, 234)
			sl.Parent = x
			sl.Range = 60
				sp.Parent = x
				sp.SparkleColor = Color3.new(144, 25, 255)	
						f.Parent = x
	
	game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.Q then

	
local animation = Instance.new("Animation")
local humanoid = script.Parent:WaitForChild('Humanoid')			
				animation.AnimationId = "http://www.roblox.com/asset/?id=855830361"
				humanoid:LoadAnimation(animation):Play()
					wait(1)
	if ammo == 1 then
		ammo = 0
local clx = x:Clone()
local clf = f:Clone()
	clx.Parent = game.Workspace
	clx.CFrame = character.UpperTorso.CFrame * CFrame.new(0,0,0)
	clf.Parent = clx
		
		clx.Touched:FindFirstChild('Humanoid')
			if Humanoid.Parent.Parent.Name == "iizWishzii" then return
			elseif Humanoid.Parent.Parent.Name == "iizWishzii" then
				Humanoid.Health = 0
			end
		
		game.Debris:AddItem(clx, 10)
		wait(10)
		ammo = 1
		end
	end
end) 

This is the part of code that isnt working.

clx.Touched:FindFirstChild('Humanoid')
			if Humanoid.Parent.Parent.Name == "iizWishzii" then return
			elseif Humanoid.Parent.Parent.Name ~= "iizWishzii" then
				Humanoid.Health = 0
			end

4 comments

0

so u edited the code on line 59

0

What line showed the error? If an error was return though, could you please provide it? :) Thanx C;

0

clx must be a base part and Touched is a event which is a RBXScriptSignal. The RBXScriptSignal does not have a FindFirstChild function.

0

Ohhh Ty all! :3

1 answer

✓ Accepted answer

.Touched is an event (RBXScriptSignal) fired when something touches a BasePart. You cannot use FindFirstChild on RBXScriptSignals because they aren't seen in the explorer, therefor you'd never need to get the children of it. In order to fix this, you'll need to use :connect to connect a function to the RBXScriptSignal, like so:

clx.Touched:connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") then
		Humanoid = part.Parent.Humanoid
		if Humanoid.Parent.Name ~= "iizWishzii" then
			Humanoid.Health = 0
		end
	end
end)

I edited your code to first check if the part's parent (if a character touches the block it will return the limb that touched it, e.g. LeftLeg) has a Humanoid in it before doing anything else, to prevent errors. Then you needed to define Humanoid before trying to reference it. And finally, you didn't need the first 'if' statement, just check if their name ISN'T iizWishzii, not if it is and then isn't. The code could use more work, but I'm only helping you with the question.

1 comment

0

Thank you very much! I finally understand now and I can't believe I made that code to check if it was my name LOL Im so dumb sometimes

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