Touched is not a vaild member of Serverscriptservice

  1. What do you want to achieve?
    I currently working on ice magic to my fighting game

  2. What is the issue?
    The issue is that touched is not a valid member of Serverscriptservice

  1. What solutions have you tried so far?

I trying to figuring this myself but had no idea.

Here’s the script:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent then
		if hit.Parent.Name == script.Player.Value or hit.Parent.Parent.Name == script.Player.Value then return end
		script.Disabled = true
		hit.Parent.Humanoid:TakeDamage(script.DamageTaken.Value)
		
		local folder = workspace:FindFirstChild("DebrisFolder") or Instance.new("Folder",workspace)
		folder.Name = "DebrisFolder"
		
		local function effect()
			local bolt = Instance.new("Part",folder)
			bolt.Name = "Effect"
			bolt.BrickColor = BrickColor.new("Maroon")
			bolt.Material = "Neon"
			bolt.Transparency = 0
			bolt.Size = Vector3.new(0.2,0.2,0.2)
			bolt.CanCollide = false
			bolt.Anchored = false
			bolt.CFrame = hit.CFrame
			
			local Movement = Instance.new("BodyVelocity", bolt)
			Movement.Velocity = Vector3.new(math.random(-30,30), math.random(-30,30), math.random(-30,30))
			Movement.P = math.random(10,20)
			game.Debris.AddItem(bolt,1)
		end
		
		for i = 1,50 do
			effect()
		end
	end
end)

is there any solution to fix this? if it is, please answer me.

Is this script inside the part?

1 Like

No, it’s not script that in the part.

So, if I’m understanding this correctly, your script is inside serverscriptservice.

Your script says:
script.Parent.Touched:Connect(function(hit)

To use this for the trigger for your function, you’d have to put the script inside a part. Then the scripts Parent would be the part.
Then when the part is Touched, this function would run.

But if your script is inside ServerScriptService it’s going to error. Because there is no “touched” event for ServerScriptService, because there is no way for the character to touch it.

I hope this makes sense.

script.Parent will refer to ServerScriptService instead of the part. Try moving this script into a part.

2 Likes