How to detect if player clicked on screen with Server Script

I want it to detect if the player clicks on the pantry outside the UI

So when clicked on screen not ClickDetector not Button not UI Not with LocalScript

2 Likes

Use a RemoteEvent and player:GetMouse() (client-sidedly)

1 Like

Can you be a little more clear with your instructions?

You need to record the player clicking with their mouse, this has to be done client-sidedly, unless you would use a tool. You could record the player’s postion by using game:GetService("Players").LocalPlayer:GetMouse() and then using and then using mouse.Hit, this will return a CFrame

Then you should send via a RemoteEvent the data you gathered to a server-sided script.
For the client they should fire the remote event like so: RemoteEvent:FireServer(mouse.Hit) and for the server they should receive the data like so:

local function onClickEvent(playerWhoClicked, cframeOfWhereThePlayerClicked)
   
end

RemoteEvent.OnServerEvent:Connect()
1 Like

It depends if what they are saying is, if they want to click on a part, which by the looks of things, they are. Not sure if I’m the only person not understanding.

I mean it seems pretty clear as the topic’s title is “on screen”, but if you want to click a part/model you should use ClickDetector instead.

I found how I can do:

When detect with Tool

  1. Set CoreGuiEnabled Backpack false
  2. Give Tool to player’s Character
  3. make script and put ServerScript to Tool

ServerScript:


script.Parent.Activated:Connect(function()
	print("Player Clicked on Screen or UI but not Button")
end)
1 Like

I don’t want move clickdetector’s parent’s Position always,

but if I don’t want use tool, that can be useable