local UIS = game:GetService("UserInputService") -- Service used to get the key pressed by a player UIS.InputBegan:Connect(function(input,gameProcessed) if input.UserInputType == Enum.UserInputType.Keyboard or input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Gamepad1 or input.UserInputType == Enum.UserInputType.Gamepad2 or input.UserInputType == Enum.UserInputType.Touch then if input.KeyCode == Enum.KeyCode.E or input.KeyCode == Enum.KeyCode.ButtonX then -- for keyboards and XBOX Controllers if UIS:GetFocusedTextBox() == nil then for i,v in pairs(game.Workspace.Stove["Stove1"]:GetChildren()) do local mag = (v.Parent.Union.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude if mag <= 10 then local stoveLevel = v.Parent.stoveLevel -- A boolValue game.ReplicatedStorage.StoveCall:FireServer("Stove",StoveLevel.Value) end end end end script.Parent.MouseButton1Click:Connect(function() if UIS:GetFocusedTextBox() == nil then for i,v in pairs(game.Workspace.Stove["Stove1"]:GetChildren()) do local mag = (v.Parent.Union.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude if mag <= 10 then -- If the magnitude is less than or equal to 10 studs then local StoveLevel = v.Parent.StoveLevel game.ReplicatedStorage.StoveCall:FireServer("Stove",StoveLevel.Value) end end end end) end end) while wait() do script.Parent.Visible = false for i,v in pairs(game.Workspace.Stove["Stove1"]:GetChildren()) do local stove = v.Parent mag = (stove.Union.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude if mag <= 10 then -- If the magnitude is less than or equal to 10 studs then local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(lucky.Union.Position) script.Parent.Visible = true script.Parent.Position = UDim2.new(0,WSP.X,0,WSP.Y) script.Parent.TextLabel.Text = "Open 'Stove'" end end end
Okay. This LocalScript is inside StarterGui > Keybind > ImageButton. if a player gets near the stove a Gui[with WSP] will popup, if you click the 'E' button, it will FireServer a RemoteEvent ~~and a script in ServerScriptService will print the stove level and the player's name.~~ But I expected that if you click with a computer mouse, it will work the same, but the
script.Parent.MouseButton1Click:Connect(function()
will only work when using emulators(touch). How would I make it so that it will work in computer mouses?