Remote Event: Local Script -> Script Not Working

  1. What do you want to achieve? My Remote Event script that enables a gui and unlocks the mouse to run. (game is in first person)

  2. What is the issue? When I click the part that triggers the script to FireServer(), nothing happens. (Issue recorded on mobile because my computer’s recorder isn’t the best quality.)

  1. What solutions have you tried so far? Changing my scripts and looking on the DevForum

Local Script in part that you click

local Event = game.ReplicatedStorage.DrawerEvent
local ClickDetector = game.Workspace.Map.House.Cabinet.Drawer.DrawerNote.ClickDetector

ClickDetector.MouseClick:Connect(function()
	local InputService = game:GetService("UserInputService")
	InputService.MouseBehavior = Enum.MouseBehavior.Default
	Event:FireServer()
end)

Script In ServerScriptService

local Event = game.ReplicatedStorage.DrawerEvent
local Detector = game.Workspace.Map.House.Cabinet.Drawer.DrawerNote.ClickDetector
local Note = game.Workspace.Map.House.Cabinet.Drawer.DrawerNote

Event.OnServerEvent:Connect(function(plr)
	local Gui = plr.PlayerGui:WaitForChild("DrawerPage")
	Note.Transparency = 1
	Gui.Enabled = true
end)

does the Event Fire? Check this by adding a print statement inside of the event.
this could be whatever like print(“test”)

it did not fire, so it’s a problem with the local script?

i think the problem is that your using a mouseclick event inside a local script.

Why are you trying to change a Gui on the server?

I’m trying to make it so a gui shows up and your mouse gets unlocked, but I don’t think you can enable a gui from a local script

its because your localscript is probably in workspace.
and localscripts doesn’t run in workspace.
you can put the localscript in StarterCharacterScripts

I believe you cannot enter PlayerGui on the server, and only from the local plr

Screen Shot 2022-08-02 at 3.59.11 PM

I have the local script in a part, but should I put it in startercharacterscripts?

yes you should put it there, localscripts doesn’t run in workspace.
but keep the part in workspace.

1 Like

the gui appears now, but my mouse doesn’t unlock

also, you must not make the GUI visible in a serverscript you can do it like that in a localscript.

local Event = game.ReplicatedStorage.DrawerEvent
local ClickDetector = game.Workspace.Map.House.Cabinet.Drawer.DrawerNote.ClickDetector
local Note = game.Workspace.Map.House.Cabinet.Drawer.DrawerNote
ClickDetector.MouseClick:Connect(function()
	local InputService = game:GetService("UserInputService")
	InputService.MouseBehavior = Enum.MouseBehavior.Default
	local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("DrawerPage")
        if gui then
        Note.Transparency = 1 -- ClientSided Transparency
        Gui.Enabled = true
end)

click detector i believe only operates on the server side i think. correct me if im wrong

nope, ClickDetectors can be either Fired from a localscript or a serverscript.

well i recomment doing it on the server side, and btw local scripts cannot run in workspace.

everything but mouse unlock is working

do you mean mouse lock isn’t working?

InputService.MouseBehavior = Enum.MouseBehavior.Default

The game is in first person and I want to make it so when you open the gui your mouse gets unlocked

thats the case, localscripts doesn’t run in workspace.

yh thats why i told him to run the code on the server side