I am trying to make a ServerScript that needs to detect gui button presses. My script does not highlight as an invalid operation, but it simply doesnt work. I don't want to have to use a localscript, as i would like to make this a requireable modulescript.
CloseButton = game.Players.pname.PlayerGui.Gui.Frame.Button CloseButton.MouseButton1Down:connect(function() digga.Enabled = false end)
Edit: Just to fully clarify this, i do not want to use a RemoteFunction or RemoteEvent as a method, plainly because i want to be able to make a ModuleScript with this in, upload it to Roblox and Require() it in a ServerScript. If you do not know how to solve this without the direct use of a pre-existing LocalScript then your method is not what i'm looking for.
let's say this is your module script (remember to put it somewhere the localplayer can access like replicatedstorage or workspace)
local module = {} module.Model = game.Workspace.Model function module.CloneModel() local modelClone = module.Model:Clone() modelClone.Parent = game.Workspace end return module
require module from localscript and call it's clone model function
module = require(game.Workspace.ModuleScript) module.CloneModel()
alternatively, you could get the model from the module script and clone the model in the local script:
module = require(game.Workspace.ModuleScript) model = module.Model local modelClone = model:Clone() modelClone.Parent = game.Workspace
Create a remote event object in the replicated storage and name it "spawnModel"
fire the remote event to send to the server when the player clicks a button
closeButton = script.Parent.Frame.Button closeButton.MouseButton1Down:connect(function() game.ReplicatedStorage.spawnModel:FireServer("modelNameGoesHere") end)
Have a function be called when that remote event gets fired spawning the model:
--function that spawns our model local function spawnModel(player, modelToSpawn) local model = game.ReplicatedStorage:FindFirstChild(modelToSpawn) --clone the model into the workspace if the model exists if(model)then local modelClone = model:Clone() modelClone.Parent = game.Workspace end end --connect the remote event to the function game.ReplicatedStorage.spawnModel.OnServerEvent:Connect(spawnModel)
User input such as this cannot be detected from the server, it has to be picked up by a local script, you can definitely use a ModuleScript and require it localside, and then pass it onto the server any way you want, but there is no definite way for the server to pick up client input.