Local Touched Event not triggering Server Script?

I am currently working on my “Find the Frogs” game, and I’m encountering an issue which only recently popped up with one of the special frogs. I have a regular script in the server script service which (simply) detects if a frog’s primary part (which serves as a collision detection box) has been touched, and fires an event to the client:


for i, frog in pairs(workspace.allFrogs:GetChildren()) do
frog.PrimaryPart.Touched:Connect(function(hit) –- If the collider is touched
if game.Players:GetPlayerFromCharacter(hit.Parent) then –- Check if touched by player
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local FoundFrogEvent = game.ReplicatedStorage.Events.FoundFrogPopup

		if not game.Players:GetPlayerFromCharacter(hit.Parent).FROGS:FindFirstChild(frog.Name) then -- Check if the player has already collected
			local frogVal = Instance.new("StringValue") -- If not >> save the collected frog value
			FoundFrogEvent:FireClient(player, frog.Name, frog) -- send req. for gui popup
			frogVal.Name = frog.Name
			frogVal.Parent = game.Players:GetPlayerFromCharacter(hit.Parent).FROGS -- parent value to the player's frog collected cache
		end
	end
end)

end

A script that was previously working, being a local script in Starter player scripts has stopped working :


local OSF = workspace.allFrogs:WaitForChild(“Orange Striped Frog”)
local collide = OSF.PrimaryPart
local button = workspace.MapButtons:WaitForChild(“FrogButton”)
local clickDetect = button:WaitForChild(“ClickDetector”)

clickDetect.MouseClick:Connect(function()
print(“Clicked”)
collide.CanTouch = true
end)

When touched in game, the server script does not trigger the event. I checked in the explorer too and it says the CanTouch property is set to true.
Any Ideas as to why this is not working please? Thank You :slight_smile:

2 Likes

Have you set an event for when the RemoteEvent gets called?

-- localscript

YOUR_REMOTE_NAME.OnClientEvent:Connect(function()
    -- code here
end)
1 Like

Yes, I do in a separate script which handles the popup for the gui. The gui only pops up if the frog’s name/ID is not saved in the player.