Touched Is not a valid member

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    To damage the players or humanoid
  2. What is the issue? Include screenshots / videos if possible!
    its saying touched is not a valid member of script
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i havent found any
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
--ServerScript


sp=script.Parent


local damage=34
local sounddebounce=.5

local check=true
local lastsound=0
local debris=game:GetService("Debris")


sp.Touched:connect(function(hit)
	if hit and hit.Parent then
		if lastsound+sounddebounce<time() and hit.CanCollide then
			lastsound=time()
			local sound=sp:FindFirstChild("Sound")
			if sound then
				sound.Volume=math.min(sp.Velocity.magnitude/40,1)
				sound.Pitch=.5+math.random()
				sound:Play()
			end
		end
		if damage>0 then
			local h=hit.Parent:FindFirstChild("Humanoid")
			if h and h.Health>0 then
				local targetplr=game.Players:GetPlayerFromCharacter(hit.Parent)
				local creatortag=sp:FindFirstChild("creator")
				print("Creator:",creatortag,creatortag.Value)
				print("Targetplr:",targetplr)
				if not creatortag or not creatortag.Value or not creatortag.Value.Parent==game.Players or not targetplr or targetplr~=creatortag.Value and (creatortag.Value.Neutral or targetplr.Neutral or targetplr.TeamColor~=creatortag.Value.TeamColor) then	
					if creatortag then
						for _,v in pairs(h:GetChildren()) do
							if v.className=="creator" then
								v:remove()
							end
						end
						local newcreatortag=creatortag:clone()
						debris:AddItem(newcreatortag,3)
						newcreatortag.Parent=h
					end
					h:TakeDamage(damage*math.min(sp.Velocity.magnitude/40,1))
					damage=0
				end
			end
		end
	end
end)

wait(5)

sp:remove()

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

is sp a part or what is it? (touched only works on parts)

sp is a tool soo i guess i would say a part

sp = scrpt.Parent which is a tool

you can’t do that, tool does not have a touched property

Tools do not have a .Touched event, maybe you want to refer to the tool’s handle.
Try changing the line:

sp=script.Parent

To:

sp=script.Parent.Handle

ok thx for telling me i want to see if this works

does not work at all infact it broke my whole tool

wait maybe i could show you the other script
hold on

Mind showing the explorer hierarchy?

ok yeah hold on for sure ok this wont take but atleast a minute


--Local Script

sp=script.Parent


local cooldown=10
local jetheight=200
local jetdistance=2000
local jetspeed=300
local talkinggrip=CFrame.new(-1.5,-.5,.65)*CFrame.Angles(-.2,3.14159,0)
local holdinggrip=CFrame.new(0,-.35,.1)*CFrame.Angles(.4,-.9,0)


local debris=game:GetService("Debris")
local check=true
local laststrike=sp:WaitForChild("LastStrike")
local dodgeballscript=sp:WaitForChild("DodgeballScript")

local function createdodgeball(pos,velocity)
	local p=Instance.new("Part")
	p.Name="Dodgeball"
	p.Material="Concrete"
	p.BrickColor=BrickColor.new(math.random()>.5 and "Bright red" or "Bright blue")
	p.Elasticity=1
	p.CanCollide=true
	p.Locked=true
	p.TopSurface="Smooth"
	p.BottomSurface="Smooth"
	p.formFactor="Custom"
	p.Shape="Ball"
	
	local sound=Instance.new("Sound")
	sound.SoundId="http://www.roblox.com/asset/?id=112503990"
	sound.Parent=p
	
	local creatortag=Instance.new("ObjectValue")
	creatortag.Value=game.Players.LocalPlayer
	creatortag.Name="creator"
	creatortag.Parent=p
	
	local s=dodgeballscript:clone()
	s.Parent=p
	s.Disabled=false
	
	p.Size=Vector3.new(3,3,3)
	p.CFrame=CFrame.new(pos)
	p.Velocity=velocity
	debris:AddItem(p,3)
	p.Parent=game.Workspace
end

function onEquipped(mouse)
	equipped=true
	local plr=game.Players.LocalPlayer
	sp.Grip=holdinggrip
	if mouse~=nil and plr~=nil then
		if tick()-cooldown<laststrike.Value then
			mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
			wait(laststrike.Value-(tick()-cooldown))
			mouse.Icon="rbxasset://textures\\GunCursor.png"
		else
			mouse.Icon="rbxasset://textures\\GunCursor.png"
		end
		mouse.Button1Down:connect(function()
			if tick()-cooldown>laststrike.Value and mouse.Target and mouse.Target~=nil and mouse.Hit then
				local location=mouse.Hit.p
				local chr=sp.Parent
				if chr and check then
					local t=chr:FindFirstChild("Torso")
					local h=chr:FindFirstChild("Humanoid")
					if t and h and h.Health>0 then
						check=false
						laststrike.Value=tick()
						mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
						sp.Grip=talkinggrip
						local sound=sp.Handle:FindFirstChild("Sound")
						if sound~=nil then
							sound:Play()
						end

						local tp=Instance.new("Part")
						tp.Transparency=.5
						tp.Name="Effect"
						tp.Anchored=true
						tp.CanCollide=false
						tp.Size=Vector3.new(0,0,0)
						tp.BrickColor=BrickColor.new("Really red")
						tp.CFrame=CFrame.new(location)*CFrame.Angles(math.pi/2,0,0)
						local me=Instance.new("SpecialMesh")
						me.MeshId="http://www.roblox.com/asset/?id=3270017"
						me.Scale=Vector3.new(10,10,1)
						me.Parent=tp
						debris:AddItem(tp,5)
						tp.Parent=game.Workspace
						delay(0,function()
							while tp and tp.Transparency<1 do
								tp.Transparency=tp.Transparency+.025
								wait(.15)
							end
							if tp then
								tp:remove()
							end
						end)

						delay(3,function()
							for i=1,30 do
								local startpos=location+Vector3.new((math.random()-.5)*100,5+50*math.random(),(math.random()-.5)*100)
								local vec=(location+Vector3.new(0,15,0)-startpos).unit
								createdodgeball(startpos,vec*(60+math.random()*70))
								wait(.2)
							end
						end)

						wait(2)
						local sound=sp.Handle:FindFirstChild("Sound")
						if sound~=nil then
							sound:Stop()
						end
						sp.Grip=holdinggrip
						wait(cooldown-2)
						mouse.Icon="rbxasset://textures\\GunCursor.png"
						check=true
					end
				end
			end
		end)
	end
end

function onUnequipped()
	equipped=false
end

sp.Equipped:connect(onEquipped)
sp.Unequipped:connect(onUnequipped)

Image

ummm @Imagine_Developing you here hello?

This should work, what’s the error message its showing?

Well when i changed the variable to the handle it just wont show the tool anymore

however if i disable the script it shows the tool again

but does no damage except throwing balls around other players

when it should do 32 damage weird

Its something else breaking because the script should be working completely fine.

local tool = script.Parent;
local handle = tool.Handle;

handle.Touched:Connect(function(hit)
	print("Part touched:", hit);
end);

image