Player can touch part only once?

Sup, I’m making a horror game with my friend where the player’s main objective is to avoid a monster, open a blast door and escape the building.

When the player open the door and exits the ending should be played and after said ending the player is sent to the main menu.

For the ending to play the player must touch an invisible exit part.

But a problem has occurred that the player can touch the part only once (The player needs to touch the part multiple times cuz the player may get the same map after a few games).

I worked on fixing the problem for hours and reading multiple posts about the same problem, but none of the solutions shown in the posts helped, nor did my attempts on fixing this.

This is the server-sided script inside the part (The server sided version’s main task is to move the player to an another folder so the game knows when to reset the map):

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		game.StarterGui.BatteryHUD.Spotted.Visible = false

		if player then
			if not player.PlayerGui.BatteryHUD.Light.Visible then
				player.PlayerGui.BatteryHUD.Light.Visible = true
				local tween = TweenService:Create(Light, tweenInfo, Goal)
				local humanoid = player.Character:FindFirstChild("Humanoid")
				humanoid.WalkSpeed = 0
				player.Character.Parent = game.Workspace.PlayerFolder.Lobby.Choosing
				player.Character.HumanoidRootPart.CFrame = CFrame.new(-595.598, -94.815, 245.13)
				tween:Play()
				Ringing:Play()
				wait(3)
				Ambience:Stop()
				Ringing:Stop()
				--Ending plays, didn't include cuz it would be too much to throw at you
				wait(2)
				KeySound:Play()
				MenuStatic:Play()
				MenuMusic:Play()
			end
		end
	end
end)

And the client-sided version of the script (Sends the player to the main menu):

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		game.StarterGui.BatteryHUD.Spotted.Visible = false

		if player then
			if not player.PlayerGui.BatteryHUD.Light.Visible then
				player.PlayerGui.BatteryHUD.Light.Visible = true
				local tween = TweenService:Create(Light, tweenInfo, Goal)
				local humanoid = player.Character:FindFirstChild("Humanoid")
				player.Character:WaitForChild("Humanoid").WalkSpeed = 0
				player.Character.Parent = game.Workspace.PlayerFolder.Lobby.Choosing
				player.Character.HumanoidRootPart.CFrame = CFrame.new(-595.598, -94.815, 245.13)
				tween:Play()
				Ringing:Play()
				wait(3)
				player.Character:WaitForChild("Humanoid").WalkSpeed = 0
				print("Client")
				Ambience:Stop()
				Ringing:Stop()
				game.Workspace.Dave.Dave.Body.Growl:Stop()
				game.Workspace.Dave.Dave.Body["Spider Footsteps 3 (SFX)"]:Stop()
--Ending plays--
				KeySound:Play()
				wait(2)
				Key:Play()
				MenuStatic:Play()
				MenuMusic:Play()
				local MenuCam = game.Workspace.CameraPart
				CurrentCam.CameraType = Enum.CameraType.Scriptable
				CurrentCam.CFrame = MenuCam.CFrame
			end
		end
	end
end)

If any more details are needed then let me know.
Any explanation behind the problem is appreciated.

4 Likes

Where is the specific issue occurring, is it with playing the ending or the receiving of the part.touched event?

1 Like

With both. When the player tries to touch the part the second time nothing happens. The player just goes trough the part.

1 Like

Does anything affect this parts canTouch property?

1 Like

Nope, it just doesn’t work the second time.

1 Like

Check using print statements if the .touched event fires at all.

1 Like

I already did, nothing prints.

1 Like

How is the map loaded in? After the first touch, does the map change at all?

1 Like

The map doesn’t change after touch, it changes after all of the players are in the main menu and voted for the next map (If players have voted for the same map it just resets the map by destroying it and cloning it back, I tried it with the exit but the exit just doesn’t work if cloned even if it is the first time touching the clone).

2 Likes

Could you describe your testing process, and how you are interacting with the part?

2 Likes

The only way to interact with the part is by touching it.
And testing, I just play the game and touch the part seeing if what I tried works.

2 Likes

Can I see how you find the part in the script. part = ?

2 Likes

Local script:

local part = game.Workspace.ExitFolder.ExitPart

And for the server script I simply use script.Parent

2 Likes

Just to make sure. The part is not interacting with the local or server script.

2 Likes

It’s not the second time the player tries to touch it.

2 Likes

Ok, look at the properties of the object before and after being touched, have they changed, also have any children changed?

2 Likes

Nothing in the properties changed nor did any children of the part.

2 Likes

Does this part have any collection service tags, or is influenced by other factors than these scripts?

2 Likes

Nope.

aaaINeed30CharactersToPostThisaaa

2 Likes

Have you checked this on the server and the client?

2 Likes