This is my first time asking a question here so I apologize in advance if I break any rules or customs.
I'm making a game where players can be 'infected', and to do this I have spheres that will kind of float around until they touch something other than a player. I have an extremely simple function that runs as soon as the .Touched event fires, and yet when I run the game the function does not fire when it touches the ground. I have searched all over the internet for an explanation of this, but was unable to solve my problem.
I did discover (Correct me if I'm wrong) that for .Touched to work, there must be a Touch Interest object parented to the Base Part that the script refers to. Normally this would be fine, but I think that because my sphere is a clone it doesn't have the touch interest. I don't really know why, but the function simply refuses to run at all. Here's my script:
coughDroplet = script.Parent coughDroplet.Touched:Connect(function(hit) print("Cough droplet has been touched") if hit.Name == "Infectable" then print("Anchoring Droplet") coughDroplet.Anchored = true else if hit.Parent.Humanoid ~= nil then print("Infecting Player") local humanoid = hit.Parent.Humanoid local player = humanoid.Parent:GetPlayerFromCharacter() game.ReplicatedStorage.TellInfectedClient:FireAllClients(player, coughDroplet.PlayerID.Value) end end end)
While I wouldn't mind figuring out why this never worked, I ended up just learning how to use ray casting instead to do what I was trying to do with .Touched. No need to answer this.